add get_url
This commit is contained in:
parent
931f780bfb
commit
c804b50ea2
1 changed files with 6 additions and 0 deletions
|
@ -131,6 +131,12 @@ class API(object):
|
||||||
form.add_field('data', json.dumps(data))
|
form.add_field('data', json.dumps(data))
|
||||||
return self._json_request(self.url, form)
|
return self._json_request(self.url, form)
|
||||||
|
|
||||||
|
def get_url(self, url):
|
||||||
|
request = urllib.request.Request(url, method='GET')
|
||||||
|
f = self._opener.open(request)
|
||||||
|
result = f.read()
|
||||||
|
return result
|
||||||
|
|
||||||
def save_url(self, url, filename, overwrite=False):
|
def save_url(self, url, filename, overwrite=False):
|
||||||
chunk_size = 16 * 1024
|
chunk_size = 16 * 1024
|
||||||
if not os.path.exists(filename) or overwrite:
|
if not os.path.exists(filename) or overwrite:
|
||||||
|
|
Loading…
Reference in a new issue