通过代理隧道 httplib [英] Tunneling httplib Through a Proxy

查看:49
本文介绍了通过代理隧道 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,如这个问题:如何在 urllib2 中使用 SOCKS 4/5 代理?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆