Created
February 13, 2020 10:53
-
-
Save cupcakearmy/7c30d5791280a27fadf04ffab1733ac7 to your computer and use it in GitHub Desktop.
Nord VPN random proxy
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 json import loads | |
from urllib.request import urlopen | |
from random import choice | |
from time import sleep | |
from html import escape | |
from requests import get | |
with urlopen("https://api.nordvpn.com/server") as url: | |
data = loads(url.read().decode()) | |
cleaned = [ | |
{ | |
'domain': item['domain'], | |
'country': item['flag'].lower(), | |
# 'features': item['features'], | |
} | |
for item in data | |
if item['features']['proxy_ssl'] and item['features']['proxy'] | |
] | |
# de = [ | |
# item | |
# for item in cleaned | |
# if item['country'] == 'de' | |
# ] | |
contries = set([ | |
item['country'] | |
for item in cleaned | |
]) | |
def get_random_proxy() -> str: | |
selected = choice(cleaned)['domain'] | |
server = f'username:password@{selected}:80' | |
return { | |
'http': f'http://{server}', | |
'https': f'https://{server}', | |
} | |
proxies = get_random_proxy() | |
print(proxies) | |
for _ in range(1): | |
ip = get('http://api.ipify.org', proxies=proxies).text | |
print('My public IP address is: {}'.format(ip)) | |
sleep(.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment