Python performs the operation of get submission

From , 3 Years ago, written in Python, viewed 53 times.
URL https://pastebin.vip/view/f3f1fa1e
  1. import sys, urllib2, urllib
  2.  
  3. def addGETdata(url, data):
  4.     """Adds data to url.  Data should be a list or tuple consisting of 2-item
  5.    lists or tuples of the form: (key, value).
  6.  
  7.    Items that have no key should have key set to None.
  8.  
  9.    A given key may occur more than once.
  10.    """
  11.     return url + '?' + urllib.urlencode(data)
  12.  
  13. zipcode = 'S2S 7U8'
  14. url = addGETdata('http://www.wunderground.com/cgi-bin/findweather/getForecast',
  15.                  [('query', zipcode)])
  16. print "Using URL", url
  17. req = urllib2.Request(url)
  18. fd = urllib2.urlopen(req)
  19. while 1:
  20.     data = fd.read(1024)
  21.     if not len(data):
  22.         break
  23.     sys.stdout.write(data)
  24.  
  25. #//python/8088

Reply to "Python performs the operation of get submission"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website