Created
December 29, 2011 02:15
-
-
Save skyl/1531186 to your computer and use it in GitHub Desktop.
Fill varnish with requests
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 urllib | |
import requests | |
exposure_liability_map = { | |
"people": [ | |
#("RESDQ", "All residents Day"), | |
("RESNQ", "Night Residents"), | |
("RESFDQ", "Female residents Day"), | |
("RESN4Q", "Night residents < 4yo"), | |
], | |
"buildings": [ | |
("RINF_BAQ", "Building Area (m2)"), | |
], | |
"infrastructure": [ | |
("PPQ", "MW capacity"), | |
], | |
"esa": [ | |
("Something", "IDK"), | |
], | |
} | |
ROOT_URL = "http://173.203.127.51/cityrisk/" | |
cities = [u'Manila', u'Ningbo'] | |
ets = [u'earthquake', u'landslide', u'typhoon', u'monsoon', u'drought'] | |
LIABILITIES = ("people", "buildings", "infrastructure", "esa") | |
def main(): | |
for city in cities: | |
for et in ets: | |
for l in LIABILITIES: | |
for exp in exposure_liability_map[l]: | |
url = "{url}?city={city}&exposure_type={exposure_type}&liability={liability}&exposure={exposure}".format(**{ | |
"url": ROOT_URL, | |
"city": city, | |
"exposure_type": et, | |
"liability": l, | |
"exposure": exp[0], | |
}) | |
print url | |
res = requests.get(url) | |
print res.headers | |
raw_input("ok? ") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment