我想通过代理 http 站点使用 urllib2,发布到具有 name="what" 的表单组件,单击提交,然后将生成的网页作为字符串返回。我知道很多人以前都问过这个问题,例如看这里。但是,我无法让他们的解决方案适用于下面的示例代码:
url = "http://anonymouse.org/anonwww.html"
posturl = "www.google.ca"
values = {'what':posturl}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
html = response.read()
print html