九月 09, 2006

Use urllib make form submission.

使用urllib提交表单:

url = "http://host/path/to/submit"
data = {submit: value}
urldata = urllib.urlencode(data)
results = urllib.urlopen(url, urldata).read()
print results

在提交时使用代理:

proxies = {'http': 'http://host:port'}
url = "http://host/path/to/submit"
data = {'submit': 'value'} # fly100%
opener = urllib.FancyURLopener(proxies)
urldata = urllib.urlencode(data)
results = opener.open(url, urldata).read()

使用cookie的提交(待续):


 


tags: ,

没有评论: