comparison readfile.py @ 9:80bf0039c0dc draft

Uploaded
author bernhardlutz
date Fri, 02 May 2014 18:16:36 -0400
parents 3c1e862e8cd6
children
comparison
equal deleted inserted replaced
8:3c1e862e8cd6 9:80bf0039c0dc
15 except urllib2.HTTPError, e: 15 except urllib2.HTTPError, e:
16 return "" 16 return ""
17 else: 17 else:
18 return connection.read().rstrip() 18 return connection.read().rstrip()
19 19
20 def store_result(url, outfile): 20 def store_result_get(url, outfile):
21 data=getresult(url) 21 data=getresult(url)
22 outfile.write(data) 22 outfile.write(data)
23 outfile.close() 23 outfile.close()
24
25 def store_result_post(url, post, outfile):
26 data = urllib.urlencode(post)
27 headers={"Content-Type" : "application/x-www-form-urlencoded"}
28 req = urllib2.Request(url, data, headers)
29 response = urllib2.urlopen(req)
30 the_page = response.read()
31 outfile.write(the_page)
32 outfile.close()