forked from JeffWSJ/weibo_checkin_spider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_poi.py
executable file
·30 lines (30 loc) · 1.59 KB
/
get_poi.py
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
#coding=utf-8
import urllib2
poi_file=open("poi.txt","a")
for i in range(1,866):#五华区的poi点数据共11页
url1="http://www.poi86.com/poi/amap/district/530102/"+str(i)+".html"#五华区的poi点数据的网址
try:
page1=urllib2.urlopen(url1)
except:
pass
if page1:
text1=page1.read()
for j in range(0,50):#每页50条数据
if "<td><a href=" in text1 and "</a></td>" in text1:
text1=text1[text1.index("<td><a href=")+1:]
text1_1=text1[text1.index("<td><a href=")+13:]
url2="http://www.poi86.com"+text1_1[:text1_1.index("html")+4]
try:
page2=urllib2.urlopen(url2)
except:
pass
if page2:
text2=page2.read()
if "火星坐标" in text2 and "百度坐标" in text2:
text2=text2[text2.index("火星坐标"):text2.index("百度坐标")]
if "</span>" in text2 and "</li>" in text2:
poi=text2[text2.index("</span>")+8:text2.index("</li>")]+"\n"
poi_file.write(poi)
print i
poi_file.flush()
poi_file.close()