Created
February 17, 2014 12:57
-
-
Save Perlence/9050051 to your computer and use it in GitHub Desktop.
Update VPNBook password
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
#!/usr/bin/python | |
import os | |
import re | |
import urllib2 | |
AUTH_FILE = '~/vpnbook-openvpn-auth' | |
resp = urllib2.urlopen('http://www.vpnbook.com/freevpn') | |
content = resp.read() | |
match = re.search(r'(?:<\w+>)?Password(?:</\w+>)?: (?:<\w+>)?([a-zA-Z0-9]{8})(?:</\w+>)?', content) | |
if match is not None: | |
with open(os.path.expanduser(AUTH_FILE), 'w') as fp: | |
fp.write('vpnbook\n') | |
fp.write(match.group(1)) | |
fp.write('\n') | |
else: | |
raise ValueError('no password found') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment