add get_url

This commit is contained in:
j 2019-03-15 11:45:08 +00:00
parent 931f780bfb
commit c804b50ea2

View file

@ -131,6 +131,12 @@ class API(object):
form.add_field('data', json.dumps(data))
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):
chunk_size = 16 * 1024
if not os.path.exists(filename) or overwrite: