3

I am trying to create a list of proxies using nordvpn for python requests, but I can't seem to figure the correct format to write the server as a proxy.

From what I understood the format is a such with this server as an example:

proxy = {
    'http': "username:password@us6181.nordvpn.com",
    'https': "username:password@us6181.nordvpn.com"
}

I have tried various combinations:

  1. my login email and password
  2. my nordvpn account username and password
  3. I realize not all servers can be used as proxy so I made sure they are
  4. I tried using udp/tcp instead of http/https

None of these attempts worked, and I really hope someone can tell me the proper way to do it.

Yasmin
  • 31
  • 1
  • 2

1 Answers1

0

Here is a simple script that i made:

import requests
from requests.auth import HTTPProxyAuth
import re
import random
#this is some proxy to use for nordvpn
#196.240.57.107
#37.120.217.219
up1 = ['username:password'
]
up2 = random.choice(up1)
u1 = re.findall(r'[\w]+:', up2)
p1 = re.findall(r':+[\w]+[\w]', up2)
u2 = str(u1)
u3 = u2.replace(':', '')
u3 = u3.replace('[', '')
u3 = u3.replace("'", '')
u3 = u3.replace(']', '')
p2 = str(p1)
p3 = p2.replace(':', '')
p3 = p3.replace('[', '')
p3 = p3.replace("'", '')
p3 = p3.replace(']', '')
proxies = {"http":"http://217.138.202.147"}
print(s)
auth = HTTPProxyAuth(u3, p3)
x = requests.get("http://ifconfig.me/ip")
print('Real ip: ' + x.text)
try:
    r = requests.get("http://ipv4.icanhazip.com", proxies=proxies, auth=auth)
    print(r.text)
except requests.exceptions.ProxyError:
    proxies = {"https":"http://217.138.202.147"}
    r = requests.get("http://ipv4.icanhazip.com/", proxies=proxies, auth=auth)
    print(r.text)

some proxies won't work you had to test them and a tester

import requests
from requests.auth import HTTPProxyAuth
import re
import random
list1 = []
def main():
    c1 = random.randint(0,230)
    c2 = str(c1)
    c3 = c2.replace("'", '')
    url = 'https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters={"country_id":' + c3 + '}'
    headers = {
        'accept': "application/json/",
        'content-type': "application/json"
        }
    response = requests.request("GET", url, headers=headers)
    rep1 = response.text
    rep2 = re.findall(r'"ip":"[\d]+.[\d]+.[\d]+.[\d]+"', rep1)
    rep3 = str(rep2)
    if '[]' not in rep3:
        rep4 = rep3.replace('"ip":"', '')
        rep4 = rep4.replace("'", '')
        rep4 = rep4.replace('"', '')
        rep4 = rep4.replace(']', '')
        rep4 = rep4.replace('[', '')
        rep4 = rep4.replace(',', '')
        rep5 = rep4.split()
        for list2 in rep5:
            list1.append(list2)
    if '[]' in rep3:
        main()
main()
for a in list1:
    try:
        prox = a
        up1 = ['username:password'
        ]
        up2 = random.choice(up1)
        u1 = re.findall(r'[\w]+:', up2)
        p1 = re.findall(r':+[\w]+[\w]', up2)
        u2 = str(u1)
        u3 = u2.replace(':', '')
        u3 = u3.replace('[', '')
        u3 = u3.replace("'", '')
        u3 = u3.replace(']', '')
        p2 = str(p1)
        p3 = p2.replace(':', '')
        p3 = p3.replace('[', '')
        p3 = p3.replace("'", '')
        p3 = p3.replace(']', '')
        proxies = {"http":"http://" + prox}
        auth = HTTPProxyAuth(u3, p3)
        r = requests.get("http://ipv4.icanhazip.com", proxies=proxies, auth=auth)
        if '<p>The following error was encountered while trying to retrieve the URL: <a' in r:
            print(prox + ' Auth failed')
        elif '<p>The following error was encountered while trying to retrieve the URL: <a' not in r:
            print(prox + ' Good')
            print('Your Ip: ' + r.text)
    except requests.exceptions.ProxyError:
        print(prox + ' Failed')
        pass

Auth Failed means you had to use more username and passwords Hope you enjoy it

amir
  • 143
  • 3
  • 10