爬虫
提莫_
将来的你,一定会感谢现在拼命的自己
展开
-
scrapy百度POI爬虫实战项目代码(七)-各种坐标互转
# -*- coding: utf-8 -*-import jsonimport urllibimport mathx_pi = 3.14159265358979324 * 3000.0 / 180.0pi = 3.1415926535897932384626 # πa = 6378245.0 # 长半轴ee = 0.00669342162296594323 # 偏心率平方class Geocoding: def __init__(self, api_key):原创 2020-10-27 10:51:55 · 418 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(五)
middlewares.py ------------------------------------------------# Define here the models for your spider middleware## See documentation in:# https://docs.scrapy.org/en/latest/topics/spider-middleware.htmlfrom scrapy import signals# useful for handli原创 2020-10-26 14:11:01 · 211 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(六)-bdMercator_to_bdwgs84
xu = 6370996.81Sp = [1.289059486E7, 8362377.87, 5591021, 3481989.83, 1678043.12, 0]Hj = [75, 60, 45, 30, 15, 0]Au = [[1.410526172116255e-8,0.00000898305509648872,-1.9939833816331,200.9824383106796,-187.2403703815547,91.6087516669843,-23.38765649603339原创 2020-10-26 14:09:28 · 268 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(四)
settings.py --------------------------------------------# Scrapy settings for mapbarSpider project## For simplicity, this file contains only settings considered important or# commonly used. You can find more settings consulting the documentation:##原创 2020-10-26 14:08:04 · 316 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(三)
piplelines.py -------------------------------# Define your item pipelines here## Don't forget to add your pipeline to the ITEM_PIPELINES setting# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html# useful for handling different item ty原创 2020-10-26 14:06:36 · 147 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(二)
mapbar.py 爬虫文件--------------------------------import scrapyfrom mapbarSpider.items import AddressItemfrom copy import deepcopyfrom mapbarSpider.geocode_2 import BaiDuMercatorToWgs84from mapbarSpider.geocode import Geocodingimport json#全国各城市地名抓取,包含街道原创 2020-10-26 14:05:06 · 387 阅读 · 0 评论 -
scrapy百度POI爬虫实战项目代码(一)
run.py 位置根settings.py同级别-----------------------------------from scrapy.cmdline import executeimport sysimport os# 获取当前脚本路径dirpath = os.path.dirname(os.path.abspath(__file__))print(dirpath)# 添加环境变量sys.path.append(dirpath)# 启动爬虫,第三个参数为爬虫nameexecute原创 2020-10-26 14:03:15 · 233 阅读 · 0 评论 -
百度地图POI数据采集方案以及开发环境搭建
#获取百度地图POI数据一(详解百度返回的POI数据) http://lbsyun.baidu.com/index.php?title=webapi 数据量标准可以参看 http://lbsyun.baidu.com/apiconsole/key#/home 额度管理=>开发者权益 余慕白 博客 https://www.cnblogs.com/yumubaime/p/7172954.html1.模拟HTTP请求的方式获取其上的POI数据 打开网页的调试面板可以清楚的看到这些请求 ,以及服务器原创 2020-10-26 10:00:37 · 2881 阅读 · 2 评论 -
Scrapy笔记:Scrapy爬取数据在Pipeline数据入库时,偶尔出现数据重复插入的情况
问题描述:用Scrapy来爬取某论坛数据,在数据导入mysql数据库中,一直有个别数据重复插入。修改之前代码:class AyncMysqlPipeline(object): # 初始化数据库连接 def __init__(self): dbparms = dict( host='127.0.0.1', db='j...转载 2019-07-27 20:07:07 · 531 阅读 · 0 评论 -
scrapy主动退出爬虫的代码片段
self.crawler.engine.close_spider(self, '结束爬虫!')1,此行代码是写在spider文件中的2,虽然这一行代码会停止爬虫,但是这一行代码的停止并不是立即停止原因是因为当我们不更改爬虫的setting.py文件的时候,默认配置是:# Configure maximum concurrent requests performed by Scrapy (...转载 2019-07-27 20:01:46 · 328 阅读 · 0 评论 -
scrapy动态传参
scrapy crawl baidu -a taskname=“台北” -a bound="{“left”: 116.29203277476964,“right”: 116.318“: 39.77001007727141,“bottom”: 39.74890812939301}” -a seed=“136.2,36.44”class QiubaiSpider(scrapy.Spider):...原创 2019-04-10 22:15:21 · 594 阅读 · 0 评论 -
提高scrapy的爬取速度
爬取大量数据的时候,爬取速度显著影响着爬取用时,总结一下我在使用scrapy的时候用来提升爬取速度的方法。在settings.py中设置如下参数:DOWNLOAD_DELAY = 0CONCURRENT_REQUESTS = 100CONCURRENT_REQUESTS_PER_DOMAIN = 100CONCURRENT_REQUESTS_PER_IP = 100COOKIES_EN...转载 2019-04-04 19:48:23 · 840 阅读 · 0 评论 -
解决Scrapy性能问题——案例五(Item并发太多导致溢出)
症状:爬虫对于每个Response都产生了多个Item,系统的吞吐量比期望的要低,并且可能会出现和前一个案例相同的下载器开/关现象。示例:这里我们假设有1000个请求,每个返回的页面有100个Item,响应时间为0.25s,Item在pipeline中的处理时间为3s。分别把CONCURRENT_ITEMS设置成从10到150的值来运行爬虫:for concurrent_items in 10...转载 2019-04-04 19:47:09 · 2401 阅读 · 1 评论 -
scrapy整合sqlite3方式
class Baidustreet02Pipeline(object):def init(self, sqlite_file, sqlite_table):self.sqlite_file = sqlite_fileself.sqlite_table = sqlite_table@classmethoddef from_crawler(cls, crawler): # 相当于sq...原创 2019-04-03 21:39:29 · 1016 阅读 · 0 评论 -
scrapy中pipeline的异步存储
import pymysql‘同步写入数据速度比较慢,而爬虫速度比较快,可能导致数据最后写入不到数据库中’‘’’1.引入twisted.enterprise.adbapi pymysql.cursors2.在settings中配置数据库连接参数3.创建pipeline,实现from_settings函数,从settings获取数据库连接参数,根据参数创建连接池对象,返回当前pipeli...转载 2019-04-03 21:31:00 · 456 阅读 · 0 评论 -
连接Redis后执行命令错误 MISCONF Redis is configured to save RDB snapshots
今天在redis中执行setrange name 1 chun 命令时报了如下错误提示:(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled...转载 2019-04-03 21:29:25 · 242 阅读 · 0 评论
分享