python怎样模拟发送 CGI 表单(METHOD=POST)?
我需要通过 POST 表单获取网页,有什么代码能简单做到吗?
是的,这里有一个使用 urllib.request 的简单例子:
#!/usr/local/bin/python
import urllib.request
# build the query string
qs = "First=Josephine&MI=Q&Last=Public"
# connect and send the server a path
req = urllib.request.urlopen("http://www.some-server.out-there"
"/cgi-bin/some-cgi-script", data=qs)
with req:
msg, hdrs = req.read(), req.info()


