-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle_jw.py
More file actions
45 lines (37 loc) · 1.47 KB
/
Copy pathgoogle_jw.py
File metadata and controls
45 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
# ---------------------------------------
# 仿照查天气,做googlemap的api读取
# http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5MDEyMDk4Mw==&appmsgid=10000176&itemidx=1&sign=42881919403184543ad80cb756f279ab
# http://www.weather.com.cn/data/cityinfo/101010100.html
# http://maps.google.com/maps/api/geocode/json?address=地点名称&sensor=false
# ---------------------------------------
import urllib2
import json
# from city import city
cityname='beijing'
# url='http://maps.google.com/maps/api/geocode/json?address='+cityname+'&sensor=false'
# # print url
# web=urllib2.urlopen(url)
# content=web.read()
# print content
# citycode = city.get(cityname)
citycode=str(cityname)
# if citycode:
# # url = ('http://www.weather.com.cn/data/cityinfo/%s.html' % citycode)
# url = 'http://maps.google.com/maps/api/geocode/json?address=' + cityname + '&sensor=false'
# # print url
# # content = urllib2.urlopen(url).read()
# # print content
f = file('country2.py')
# data = f.read()
data = f.readlines()
print data[0]
f.close()
for countryname in data:
print countryname
if countryname:
# url = ('http://www.weather.com.cn/data/cityinfo/%s.html' % citycode)
#url = 'http://maps.google.com/maps/api/geocode/json?address=' + countryname + '&sensor=false'
url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' + countryname + '&sensor=false&language=zh-CN'
print url
# print urllib2.urlopen(url).read()