Skip to content

Instantly share code, notes, and snippets.

@Perlence
Created February 17, 2014 12:57
Show Gist options
  • Save Perlence/9050051 to your computer and use it in GitHub Desktop.
Save Perlence/9050051 to your computer and use it in GitHub Desktop.
Update VPNBook password
#!/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