基于python的web表单提交方法,pythonweb表单,[Python]代码#!
基于python的web表单提交方法,pythonweb表单,[Python]代码#!
[Python]代码
#!/usr/bin/env python#--coding = UTF-8--#auth:@xfk#date:@2012-04-24#简单的web表单提交方式:GET和POST方法import sys,urllib2,urllibzipcode = sys.argv[1]def GET(): def addGETdata(url,data): """ Adds data to url.Data should be a list or tuple consisting of 2_item lists or tuples of the form: (key,value). Item that have no key should have key set to None. A given key may occur more than once. """ return url + '?' + urllib.urlencode(data) url = addGETdata("你的url地址",[("你要访问的网页",zipcode)]) #example:url = addGETdata("http://www.xxxxxx.com/xxx/",(["query",zipcode])) print "Using URL",url req = urllib2.Request(url) fd = urllib2.urlopen(req) while 1: data = fd.read(1024) if not len(data): break sys.stdout.write(data)def POST(): url = "你的url地址"#example:url = "http://www.xxxxxx.com/xxx/" data = urllib2.urlencode([("你要访问的网页",zipcode)]) req = urllib2.Request(url) fd = urllib2.urlopen(req,data) while 1: data = fd.read(1024) if not len(data): break sys.stdout.write(data)
相关内容
- rsync同步管理工具,rsync同步工具,[Python]代码#/
- 有一位农场主的遗嘱:第1个儿子分100美元和剩下财产的
- django 获取用户输入,django获取用户,[Python]代码#u
- 一些两位数加上18,它们的个、十位恰好位置对调了,
- 生成文件的MD5和sha1,生成文件MD5sha1,生成文件的MD5和
- 批量转换html内的&#XXXXX;为中文,且转换文件编
- python用户登陆邮件通知,python邮件通知,[Python]代码#!
- Python 压缩文件(1),python压缩文件,import os i
- python抓取百度音乐盒榜单的音乐,python抓取,[Python]代码
- python登录猫扑打卡,python猫扑打卡,[Python]代码#
评论关闭