Mercurial > repos > bernhardlutz > rest_tool
annotate readfile.py @ 8:3c1e862e8cd6 draft
Uploaded
author | bernhardlutz |
---|---|
date | Fri, 02 May 2014 05:40:28 -0400 |
parents | 54358dfa62c0 |
children | 80bf0039c0dc |
rev | line source |
---|---|
4 | 1 #!/usr/bin/env python |
2 | |
3 import io | |
4 import urllib2, urllib, httplib | |
5 def getListFromFile(file): | |
6 idlist=[] | |
7 for line in file: | |
8 if int(line): | |
9 idlist.append(line.strip()) | |
10 return idlist | |
11 | |
12 def getresult(url): | |
13 try: | |
14 connection = urllib2.urlopen(url) | |
15 except urllib2.HTTPError, e: | |
16 return "" | |
17 else: | |
18 return connection.read().rstrip() | |
19 | |
8 | 20 def store_result(url, outfile): |
21 data=getresult(url) | |
22 outfile.write(data) | |
23 outfile.close() |