Created
April 10, 2016 18:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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