Last active
December 25, 2017 08:20
-
-
Save ni554n/995d52147de317170a0e73c312431832 to your computer and use it in GitHub Desktop.
A Python 3 script to copy latest VPNBook password to clipboard.
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/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