google地图怎么批量获取经纬度
发布网友
发布时间:2022-06-21 20:36
我来回答
共1个回答
热心网友
时间:2024-12-12 22:46
[代码]利用google地图根据地址批量获取经纬度
?
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
#!/usr/bin/python
#-*- coding:utf-8 -*-
"""
根据地区进行探测,并进行日志打印,防止出错重新开始;并设置了简单的速度处理
作者:索隆
"""
import time
import urllib2
import logging.config
logging.config.fileConfig("logging.conf")
log = logging.getLogger('number')
with open("result.txt") as rf:
with open("latlng.txt","a+") as wf:
results = []
for num,line in enumerate(rf.readlines(),1):
if num%100 == 0:
log.info(str(num))
if num%2000 == 0:
wf.writelines(results)
wf.flush()
results = []
# time.sleep(20*60)
# time.sleep(15)
time.sleep(0.5)
response = urllib2.urlopen("http://ditu.google.cn/maps/geo?q=%s&output=csv"%(line.split("\t"))[2].strip())
html = response.read().decode("gbk").encode("utf-8")
results.append(html+'\n')
print html