StockAlertBot
StockAlertBot copied to clipboard
Refresh proxy list from webshare every 20 minutes
Contribution
I've created a python script to make things easiers for users who have their WebShare proxy list refresh periodically. The script periodically downloads a user's proxy list from WebShare every 20 minutes to config/proxies.txt
and reformats each proxy address to username:password@ip:host
form. Any feedback would be appreciated :)
WebShare Proxy List API
In your WebShare dashboard, click Download Proxy List
Then, copy the Proxy List API URL:
Setup
🔧 Below is the setup process for the
proxy-refresh.py
file.
Change the url
variable here to your WebShare Proxy List API url:
def get_proxies():
dir_path = os.path.dirname(os.path.realpath(__file__))
url = 'your-webshare-url'
filename = dir_path + '/' + 'config' + '/' + 'proxies.txt'
Adjust the regex pattern using the username
and password
values from your WebShare dashboard:
pattern = re.compile("(^.*)(:)(username:password)")
If you'd like to adjust the scheduling interval, you can do so by changing 20
to some other value here:
schedule.every(20).minutes.do(get_proxies)
while 1:
schedule.run_pending()
time.sleep(1)
Run Script
Finally, you can run the script using the following command:
> python3 proxy-refresh.py
💡 Congratulations! Your proxy list will automatically refresh every 20 minutes.
Hey @alif-munim, thanks for your contribution!
Sorry for the super late feedback. Excuse my ignorance, but doesn't Webshare allow you to use a rotating proxy that essentially fixes the issue you're trying to solve. They provide you with one proxy endpoint which assigns a random IP address from your proxy list. Plus, it gives you the option to rotate and refresh that proxy list. You can simply place that one proxy endpoint in config/proxies.txt
.