问题
I have to following problem. I need to check if certain urls are working and returning a correct response. I want to use python requests for this. However the urls have a redirect in it if the device or geo is incorrect and we need to check a lot of urls for mobile sites and multiple geo's.
Is there a way to work through a VPN with Python requests?
Edit: I forgot to mention, this is for a ubuntu 14.04 server. So not a home pc. On my laptop I use HideMyAss and IpVanish but I want to run a cron job on my server to check it automatically. I don't need to hide any information so I can use a proxy as well.
回答1:
Depending on the OS you use, these options are available:
- If OS X: use the Apple's Automator scripts to switch VPN connections (provided they are set up beforehand). You can use then a bash script which will wrap your python script and switch connections (based on URL, for example)
- Use a list of proxies (not VPNs). This is the easiest solution
- Use a custom VPN connection management, something like this: https://gist.github.com/domenkozar/1547663 This option will require a lot of work though.
来源:https://stackoverflow.com/questions/35132154/use-vpn-with-python-requests