利用google地图根据地址批量获取经纬度,,利用google地图根据
利用google地图根据地址批量获取经纬度,,利用google地图根据
利用google地图根据地址批量获取经纬度
result.txt中保存的是经过处理的qq ip数据库,可以处理全国所有ip地址,result.txt格式为:
61.154.21.185 61.154.31.188 福建省福州市
#!/usr/bin/python#-*- coding:utf-8 -*-""" 根据地区进行探测,并进行日志打印,防止出错重新开始;并设置了简单的速度处理 作者:索隆"""import timeimport urllib2import logging.configlogging.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#该片段来自于http://byrx.net
相关内容
- 上个程序提到的isin,程序提到isin,[Python]代码de
- 提取MD5值一样(或不一样)的文件,和后缀名一样的文
- python发送HTTP请求,python发送请求,GET 方法>>> im
- try...finally 异常,try...finally,异常处理import t
- 文件读写,,文件读写#第九章 文件#
- 字典 暗示,字典,[Python]代码#
- 字典,,字典-基础# 字典#
- python Singleton pattern,pythonsingleton,Python singl
- while循环输出(1-10),while循环输出1-10,[Python]代码i
- python读取目录下文件并生成日志,,[Python]代码
评论关闭