Python模拟http get,python模拟get,import sys,
文章由Byrx.net分享于2019-03-23 07:03:50
Python模拟http get,python模拟get,import sys,
import sys, urllib2, urllibdef 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). Items that have no key should have key set to None. A given key may occur more than once. ''' return url + '?' + urllib.urlencode(data)zipcode = 'S2S 7U8'url = addGETdata('http://www.wunderground.com/cgi-bin/findweather/getForecast', [('query', zipcode)])print 'Using URL', urlreq = urllib2.Request(url)fd = urllib2.urlopen(req)while 1: data = fd.read(1024) if not len(data): break sys.stdout.write(data)
相关内容
- python中使用__class__, __bases__ and __dict__,__class____bases_,
- 使用类示例,类示例,#Just preten
- Python的类继承,Python类继承,class FirstC
- Class inheritance: inherit member variable override function,inheri
- python实现跳转,python跳转,#!c:/Python2
- Print out class tree,printtree,def classtre
- python面向对象:__del__函数使用,python__del_,class Life:
- python Class: __getitem__ 示例,python__getitem_,class indexe
- python输出系统用户,python输出用户,import ospri
- Provide custom type infomation,provideinfomation,class MyMeta
评论关闭