Hi everyone,
I’m building a Streamlit app that allows users to check trends on any topic using PyTrends. On my local machine, I was able to bypass Google’s bot detection by programmatically starting a VPN in Python:
import secrets, random, subprocess
password = secrets.token_urlsafe(16)
port = random.randint(10000, 60000)
print(f"Starting VPN on port {port} with password {password}")
print("VPN is running... connect with the above password and port.")
vpn_process = subprocess.Popen(
["pvpn", "-p", password, "--udp", "--port", str(port)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
This worked fine locally, but when I deploy the app on Streamlit Cloud, it doesn’t seem to work—probably because I don’t have access to run VPNs or change network settings on their servers. I also don’t have any external proxy servers.
Does anyone have suggestions on:
-
Whether there’s a way to use VPNs or rotating IPs inside a Streamlit app?
-
Why this approach is not working for streamlit cloud yet working for local machine?
Thanks in advance for any advice!