Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use vpn with python requests

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.

like image 542
user3605780 Avatar asked Feb 01 '16 13:02

user3605780


1 Answers

Depending on the OS you use, these options are available:

  1. 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)
  2. Use a list of proxies (not VPNs). This is the easiest solution
  3. Use a custom VPN connection management, something like this: https://gist.github.com/domenkozar/1547663 This option will require a lot of work though.
like image 68
Igor Avatar answered Oct 14 '22 23:10

Igor