Skip to content

Instantly share code, notes, and snippets.

@ni554n
Last active December 25, 2017 08:20
Show Gist options
  • Save ni554n/995d52147de317170a0e73c312431832 to your computer and use it in GitHub Desktop.
Save ni554n/995d52147de317170a0e73c312431832 to your computer and use it in GitHub Desktop.
A Python 3 script to copy latest VPNBook password to clipboard.
#!/usr/bin/env python3
"""
A Python 3 script to copy latest VPNBook password to clipboard.
Copy to clipboard is supported on Windows / macOS.
Author: Nissan Ahmed
"""
import os
import urllib.request
url = 'https://www.vpnbook.com'
print('Requesting...')
with urllib.request.urlopen(url) as response:
body = str(response.read())
start = body.find('<li><strong>Password:')
end = body.find('</li>', start)
password = body[start + 22: end - 9]
if os.name == 'nt':
os.system('echo|set /p=' + password + '|CLIP')
print('Copied to clipboard!')
elif os.name == 'mac':
os.system('echo ' + password + ' | pbcopy')
print('Copied to clipboard!')
else:
print(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment