Skip to content

Instantly share code, notes, and snippets.

@Zia-
Created March 18, 2019 14:12
Show Gist options
  • Save Zia-/d419b04683ad0e5da3c41a5fa8f219e9 to your computer and use it in GitHub Desktop.
Save Zia-/d419b04683ad0e5da3c41a5fa8f219e9 to your computer and use it in GitHub Desktop.
import grequests, requests, time
then = time.time()
urls = [
'https://api.ohsome.org/v0.9/elements/geometry?bboxes=8.625%2C49.3711%2C8.7334%2C49.4397&properties=tags&showMetadata=false&time=2014-01-01%2C2017-01-01&types=way',
'https://api.ohsome.org/v0.9/elements/geometry?bboxes=8.625%2C49.3711%2C8.7334%2C49.4397&properties=tags&showMetadata=false&time=2014-01-01%2C2017-01-01&types=way',
'https://api.ohsome.org/v0.9/elements/geometry?bboxes=8.625%2C49.3711%2C8.7334%2C49.4397&properties=tags&showMetadata=false&time=2014-01-01%2C2017-01-01&types=way'
]
#### Async approach
# rs = (grequests.post(u) for u in urls)
# requests = grequests.map(rs)
# for response in requests:
# print(response.content)
####
#### Sync approach
for i in range(len(urls)):
r = requests.post(url = urls[i])
print r.content
####
now = time.time()
print("It took: ", now-then, " seconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment