Skip to content

Instantly share code, notes, and snippets.

@culebron
Created March 14, 2017 21:25
Show Gist options
  • Save culebron/9f1d98507919b5a0f9109688046a505d to your computer and use it in GitHub Desktop.
Save culebron/9f1d98507919b5a0f9109688046a505d to your computer and use it in GitHub Desktop.
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)
@matkoniecz
Copy link

Note that nowadays it crashes with TypeError: request() got an unexpected keyword argument 'raw_response'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment