Skip to content

Instantly share code, notes, and snippets.

@zupo
Created April 10, 2016 18:39
Show Gist options
  • Save zupo/beecd5af11bc7f934112d8af0cd7ce09 to your computer and use it in GitHub Desktop.
Save zupo/beecd5af11bc7f934112d8af0cd7ce09 to your computer and use it in GitHub Desktop.
Parse Ghost Path's website to get a list of remotes to insert into openvpn.conf to randomly connect to one
from lxml import html
import requests
COUNTRIES = [
# 'United States',
'Austria',
'Germany',
'Hungary',
'Italy',
'Luxembourg',
'Netherlands',
]
page = requests.get('https://ghostpath.com/servers/')
tree = html.fromstring(page.content)
servers = tree.cssselect('table#server-locations tr')
for server in servers:
if server.xpath('./td/a/text()') and \
server.xpath('./td/a/text()')[0] in COUNTRIES:
print server.xpath('./td/text()')[2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment