我想使用某个网址& branch_location&然后通过我的代码循环 然后抓住下一个URL& branch_location&然后通过我的代码循环 然后抢等...我有大约50个位置,我怎么能在python 3.62中做到这一点。谢谢。
use_url = "http://api.wunderground.com/api/forecast10day/q/il/chicago.json"
branch_location = 'chicago, il'
use_url = "http://api.wunderground.com/api/forecast10day/q/ca/los angeles.json"
branch_location = 'los angeles, ca'
# code to loop thru is below
url = use_url
req = urllib.request.Request(
url,
data=None,
headers={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
}
)
f = urllib.request.urlopen(req)
json_string = f.read()
parsed_json = json.loads(json_string)
etc...