1 Star 0 Fork 0

Vivienfanghua/TestPython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wuhan.py 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
Vivienfanghua 提交于 2017-10-14 13:50 . first commit
__author__ = 'vivienfanghua'
import urllib2
from bs4 import BeautifulSoup
import codecs
import json
baseurl="http://api.map.baidu.com/place/v2/search?q=%E5%8C%BB%E7%96%97&region=%E6%AD%A6%E6%B1%89%E5%B8%82&page_size=20&page_num=pppnum&output=json&ak=ZWl4eD5D2leA0RxRw7c6hRwR"
output=codecs.open("D:/output.txt","w","utf8")
for i in range(20):
url=baseurl.replace("pppnum",str(i))
request = urllib2.Request(url)
response = urllib2.urlopen(request)
content=response.read().decode("utf-8")
js=json.loads(content)
for j in js["results"]:
name=j["name"]
telephone=""
if j.has_key("telephone"):
telephone=j["telephone"]
lat=j["location"]["lat"]
lng=j["location"]["lng"]
address=j["address"]
output.write(name+u" "+unicode(lat)+u" "+unicode(lng)+u" "+address+u" "+telephone+u"\n")
print("Done")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/vivienfanghua/TestPython.git
git@gitee.com:vivienfanghua/TestPython.git
vivienfanghua
TestPython
TestPython
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385