基本上我想做的是在我能够浏览互联网的同时能够连接到代理这是我试过的代码import webbrowserimport socks, socket, requestsfrom multiprocessing import Processdef proxy(): while True: socks.set_default_proxy(socks.SOCKS5, "184.32.91.92", 2901) socket.socket = socks.socksocketif __name__ == '__main__': proxy_process = Process(target=proxy).start() r = requests.get("http://icanhazip.com") print(r.content) # stil gives me my actual IP address webbrowser.open("http://icanhazip.com", new=2) # opening the webbrowser所以我尝试处理代理以保持连接有效但即使我打开浏览器它仍然给我我的实际 IP
1 回答

杨__羊羊
TA贡献1943条经验 获得超7个赞
看起来像一个时间问题。您的__main__
流程可能到达以下行:
r = requests.get("http://icanhazip.com")
在proxy_process
完成它的工作之前。
添加回答
举报
0/150
提交
取消