Created
March 14, 2017 21:25
-
-
Save culebron/9f1d98507919b5a0f9109688046a505d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import bz2 | |
from time import sleep | |
def overpass2bz2(request, filename): | |
resp = requests.get('https://overpass-api.de/api/interpreter', data={'data': u"""[out:xml][timeout:180];(%s);(._;>;);out meta;""" % request}, raw_response=True) | |
sleep(15) | |
if resp.status_code != 200: | |
print resp.status_code, resp.reason | |
return | |
with bz2.BZ2File(filename, 'w') as f: | |
f.write(resp.content) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that nowadays it crashes with
TypeError: request() got an unexpected keyword argument 'raw_response'