通过代理隧道化httplib [英] Tunneling httplib Through a Proxy
本文介绍了通过代理隧道化httplib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图弄清楚如何通过代理将数据发送到服务器.我希望通过tor可以做到这一点,但是由于tor使用了SOCKS,因此httplib显然是不可能的(如果我错了,请纠正我)
I am trying to figure out how to send data to a server through a proxy. I was hoping this would be possible through tor but being as tor uses SOCKS it apparently isn't possible with httplib (correct me if I am wrong)
这就是我现在拥有的
import httplib
con = httplib.HTTPConnection("google.com")
con.set_tunnel(proxy, port)
con.send("Sent Stuff")
问题是,设置隧道后,它似乎冻结了.感谢您的帮助.
The problem is, it seems to freeze when the tunnel is set. Thanks for your help.
推荐答案
如果要使用http代理,则应如下所示:
If you want to use http proxy, it should be like this:
import httplib
conn = httplib.HTTPConnection(proxyHost, proxyPort)
conn.request("POST", "http://www.google.com", params)
如果您想使用SOCKS代理,则可以按照以下问题使用SocksiPy:
If you want to use SOCKS proxy, you can use SocksiPy as in this question: How can I use a SOCKS 4/5 proxy with urllib2?
这篇关于通过代理隧道化httplib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文