Mercurial > repos > bernhardlutz > rest_tool
diff readfile.py @ 9:80bf0039c0dc draft
Uploaded
author | bernhardlutz |
---|---|
date | Fri, 02 May 2014 18:16:36 -0400 |
parents | 3c1e862e8cd6 |
children |
line wrap: on
line diff
--- a/readfile.py Fri May 02 05:40:28 2014 -0400 +++ b/readfile.py Fri May 02 18:16:36 2014 -0400 @@ -17,7 +17,16 @@ else: return connection.read().rstrip() -def store_result(url, outfile): +def store_result_get(url, outfile): data=getresult(url) outfile.write(data) outfile.close() + +def store_result_post(url, post, outfile): + data = urllib.urlencode(post) + headers={"Content-Type" : "application/x-www-form-urlencoded"} + req = urllib2.Request(url, data, headers) + response = urllib2.urlopen(req) + the_page = response.read() + outfile.write(the_page) + outfile.close()