如何使用 nord*** 服务器作为 python 请求的代理?
Posted
技术标签:
【中文标题】如何使用 nord*** 服务器作为 python 请求的代理?【英文标题】:How to use nord*** servers as proxy for python requests? 【发布时间】:2021-02-07 11:16:04 【问题描述】:我正在尝试使用 nord*** 为 python 请求创建代理列表,但我似乎无法确定将服务器编写为代理的正确格式。
据我了解,格式是这样的,以这个服务器为例:
proxy =
'http': "username:password@us6181.nord***.com",
'https': "username:password@us6181.nord***.com"
我尝试了各种组合:
-
我的登录邮箱和密码
我的 nord*** 帐户用户名和密码
我意识到并非所有服务器都可以用作代理,所以我确定它们是
我尝试使用 udp/tcp 而不是 http/https
这些尝试都没有奏效,我真的希望有人能告诉我正确的方法。
【问题讨论】:
【参考方案1】:这是我制作的一个简单脚本:
import requests
from requests.auth import HTTPProxyAuth
import re
import random
#this is some proxy to use for nord***
#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)
有些代理无法工作,您必须对其进行测试 和一个测试员
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://nord***.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
身份验证失败意味着您必须使用更多用户名和密码 希望你喜欢它
【讨论】:
以上是关于如何使用 nord*** 服务器作为 python 请求的代理?的主要内容,如果未能解决你的问题,请参考以下文章
Byte Order 在 MacOS 上复活了 Nord Modular G1 合成器编辑器
如何使用javascript作为客户端和python作为Web服务器在websocets之间进行通信