##数据来源 ###在此感谢鹅厂,所有的数据都是从鹅厂注册页面获取到的
- 输入国家名称,获取到国家ID.
- 输入省,获取到国家和省ID
- 输入城市,获取到国家、省和市ID
url = "http://tools.bugcode.cn" #####根据城市名字获取城市ID
r = requests.post(url+"/cities/search", {"country": "中国", "language": "cn", "province": "江苏", "city": "淮安"})
if r.status_code == 200:
print r.text
else:
print r.status_code
#####根据城市ID获取城市名字
-
获取所有国家
r = requests.post(url+"/cities/search", {"action": "countries", "language": "cn"}) if r.status_code == 200: print r.text else: print r.status_code
-
获取一个国家所有省份
r = requests.post(url+"/cities/search", {"action": "provinces", "language": "cn", "c_id": 1}) if r.status_code == 200: print r.text else: print r.status_code
-
获取一个国家一个省所有城市
r = requests.post(url+"/cities/search", {"action": "cities", "language": "cn", "c_id": 1, "p_id": 32}) if r.status_code == 200: print r.text else: print r.status_code
-
获取一个国家一个省一个城市
r = requests.post(url+"/cities/search", {"action": "city", "language": "cn", "c_id": 1, "p_id": 32, "i_id": 8}) if r.status_code == 200: print r.text else: print r.status_code