• 大小: 15.95MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-26
  • 语言: 其他
  • 标签: 百度地图  POI  

资源简介

基于百度地图API的POI抓取工具

资源截图

代码片段和文件信息

#  -*- coding: UTF-8 -*-

import urllib2
import re
import sys

# 引入PyQt4的模块
from PyQt4 import QtCore QtGui
# 引入Qt创建的窗体
from baidumappoi_ui import Ui_Form

class StartQt4(QtGui.QWidget):
    # 与Qt创建的窗体绑定
    def __init__(selfparent=None):
        QtGui.QWidget.__init__(self parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.connect(self.ui.button_locQtCore.SIGNAL(‘clicked()‘)self.savelocation)
        self.connect(self.ui.button_cityQtCore.SIGNAL(‘clicked()‘)self.city)
        self.connect(self.ui.button_rectQtCore.SIGNAL(‘clicked()‘)self.rect)
        self.connect(self.ui.pushButton_3QtCore.SIGNAL(‘clicked()‘)self.circle)

    # 保存文件路径
    def savelocation(self):
        fds = QtGui.QFileDialog(self)
        self.savename = fds.getSaveFileName() 
        if self.savename == ‘‘:
            pass
        else:
            self.ui.lineEdit_saveLoc.setText(self.savename)

    # 城市内检索        
    def city(self):
        try:
            # 赋值
            ak = self.ui.lineEdit_AK.text()
            uni_ak = unicode(QtCore.QString(ak).toUtf8() ‘utf-8‘ ‘ignore‘)
            saveLoc = self.ui.lineEdit_saveLoc.text()
            uni_saveLoc = unicode(QtCore.QString(saveLoc).toUtf8() ‘utf-8‘ ‘ignore‘)
            fsave = open(uni_saveLoc‘w‘)
            keyword = self.ui.lineEdit_keyword.text()
            uni_keyword = unicode(QtCore.QString(keyword).toUtf8() ‘utf-8‘ ‘ignore‘)
            label = self.ui.lineEdit_label.text()
            uni_label = unicode(QtCore.QString(label).toUtf8() ‘utf-8‘ ‘ignore‘)
            cityName = self.ui.lineEdit_city.text()
            uni_cityName = unicode(QtCore.QString(cityName).toUtf8() ‘utf-8‘ ‘ignore‘)
            # header
            user_agent = ‘Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)‘
            headers = {‘User-Agent‘: user_agent}

            reload(sys)                         
            sys.setdefaultencoding(‘utf-8‘)
        
            if label==‘‘:
                # 查询POI总数
                url1 = ‘http://api.map.baidu.com/place/v2/search?query=‘+uni_keyword+‘®ion=‘+uni_cityName+‘&page_size=1&page_num=0&scope=2&output=json&ak=‘+uni_ak
                req1 = urllib2.Request(url1 headers = headers)
                res1 = urllib2.urlopen(req1)
                content1 = res1.read().decode(‘utf-8‘)
                pattern1 = re.compile(r‘“total“:([\d\D]*?)[\d\D]*?‘)
                items1 = re.findall(pattern1content1)
                total = int(items1[0])
                # 抓取POI
                for i in range(0total):
                    url = ‘http://api.map.baidu.com/place/v2/search?q=‘+uni_keyword+‘®ion=‘+uni_cityName+‘&page_size=1&page_num=‘
                    url = url + str(i*1) + ‘&scope=2&output=json&ak=‘+uni_ak
                    req = urllib2.Request(url headers = headers)
                    res = urllib2.urlopen(req)
                    content = res.read().d

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      17363  2016-07-26 15:05  百度地图POI抓取器\baidumappoi_start.py

     文件      15355  2016-07-26 15:07  百度地图POI抓取器\baidumappoi_ui.py

     文件    2303488  2012-04-10 23:31  百度地图POI抓取器\build\bdist.win32\winexe\bundle-2.7\python27.dll

     文件       3650  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\abc.pyo

     文件       1483  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\atexit.pyo

     文件      10025  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\baidumappoi_ui.pyo

     文件       7198  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\base64.pyo

     文件      16045  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\bdb.pyo

     文件       1661  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\bisect.pyo

     文件      59904  2012-04-10 23:31  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\bz2.pyd

     文件      21483  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\calendar.pyo

     文件       7989  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\cmd.pyo

     文件      18649  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\codecs.pyo

     文件      15669  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\collections.pyo

     文件      38917  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\cookielib.pyo

     文件       9255  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\copy.pyo

     文件       4151  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\copy_reg.pyo

     文件      26928  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\difflib.pyo

     文件       5494  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\dis.pyo

     文件      45208  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\doctest.pyo

     文件       2867  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\dummy_thread.pyo

     文件        888  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\dummy_threading.pyo

     文件       2159  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\base64mime.pyo

     文件       6277  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\charset.pyo

     文件       1721  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\encoders.pyo

     文件       2355  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\errors.pyo

     文件       9153  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\feedparser.pyo

     文件       7238  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\generator.pyo

     文件       8635  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\header.pyo

     文件       1624  2016-07-26 15:36  百度地图POI抓取器\build\bdist.win32\winexe\collect-2.7\email\iterators.pyo

............此处省略235个文件信息

评论

共有 条评论