有没有办法通过Fiddler的代理隧道传递使用python的httplib
发出的HTTP请求,而不会将Fiddler变成反向代理?
我尝试使用此示例(来自here):
import httplib
c = httplib.HTTPSConnection('localhost',8118)
c.set_tunnel('twitter.com',443)
c.request('GET','/')
r1 = c.getresponse()
print r1.status,r1.reason
data1 = r1.read()
print len(data1)
但它返回:
<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>Fiddler Echo Service</TITLE></HEAD><BODY STYLE="font-family: arial,sans-serif;"><H1>Fiddler Echo Service</H1><BR /><PRE>GET / HTTP/1.1
Host: localhost:8080
Accept-Encoding: identity
</PRE><BR><HR><UL><LI>To configure Fiddler as a reverse proxy instead of seeing this page, see <A HREF='http://fiddler2.com/r/?REVERSEPROXY'>Reverse Proxy Setup</A><LI>You can download the <a href="FiddlerRoot.cer">FiddlerRoot certificate</A></UL></BODY></HTML>
编辑: 这段代码有效。该问题与Internet Explorer中的代理设置有关。请勿在这些设置中设置代理,否则上述代码将无效。
答案 0 :(得分:3)
我通过Burp代理尝试使用urllib2(Proxy with urllib2)并且它有效:
import urllib2
proxy = urllib2.ProxyHandler({'https': '127.0.0.1:8081'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
print urllib2.urlopen('https://www.google.com').read()
您的代码似乎与Burp Suite代理一起使用。