我需要从proxy.txt文件中获取代理:
ip:port:username:password并添加到代码中:
file = dbm_base()
api_id = int(file['api_id4'].decode())
api_hash = file['api_hash4'].decode()
client = TelegramClient('client4', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, 'username', 'password'))#port without ''我这样做:
with open('proxy.txt', 'r') as f:
proxys = f.readline().split(":")
file = dbm_base()
api_id = int(file['api_id4'].decode())
api_hash = file['api_hash4'].decode()
s = socks.socksocket()
client = TelegramClient('client1', api_id, api_hash, proxy=s.set_proxy(socks.HTTP, f'{proxys[0]}', int(proxys[1]), f'{proxys[2]}', f'{proxys[3]}'))但是代理服务器没有连接到脚本。
我做错了什么,为什么代理服务器没有连接?
发布于 2021-12-14 07:38:13
不确定HTTP代理或其他代理,但您可以非常轻松地使用MTPROTO代理:
server = 'firewall.firewall-gw.cam' # TODO: proxy server or ip
port = 443 # TODO: set port, normally 443
secret = 'dd00000000000000000000000000000000' # TODO: set proxy secret, normally hex encoded
connection = connection.ConnectionTcpMTProxyRandomizedIntermediate # this mode supports most proxies
client = TelegramClient('client1', api_id, api_hash, connection=connection,proxy=(server, port, secret)))MTPROXY可以从@ProxyMTProto中提取。(注:它的开源这里)
其他公共代理人的问题是,它们经常过期。
学习更多的这里。
https://stackoverflow.com/questions/70335584
复制相似问题