Git Product home page Git Product logo

finvest-spider's Introduction

finvest-spider

Finance and Investment Info Spider Collections - 投融资信息爬取集合

取Finance和Investment的前几个字母组成项目名

反爬策略

随机用户代理

此功能依赖于 fake_useragent 若出现下面的错误, 请尝试卸载该库重新安装

fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

延迟下载

settings.py 中修改下面的配置项启用延迟下载或者在爬虫的发起连接处使用 time.sleep(secs) 语句来延迟下载

# Configure a delay for requests for the same website (default: 0)
# See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
DOWNLOAD_DELAY = 10

IP 池

默认不启用,使用前请移步 middleware/ipProxy.py 爬取可用 IP,然后再运行爬虫(需要自行配置 MySQL). 启用方式: 将 settings.py 中的 RandomIpMiddleware 取消注释即可.

# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
   'middleware.customUserAgent.RandomUserAgent': 543,
   # 'finvest.middlewares.RandomIpMiddleware': 543,
}

已接入爬虫的网站

Spider名称: trjcn 行业: 综合

Spider名称: cvnews 行业: 综合

Spider名称: 36kr 行业: 综合

Spider名称: vcbeat 行业: 医疗

Spider名称: jiemodui 行业: 教育

Spider名称: gamelook 行业: 游戏

爬虫分析过程

JS动态加载以及JavaScript void(0)的爬虫解决方案

安装依赖软件

  1. 安装MongoDB 注意:以Deepin为例,如果使用Ubuntu的安装方法报错--keyserver receive failed: No dirmngr,请先键入下面命令再使用上方链接的教程 sudo apt-get install software-properties-common dirmngr

如果安装完成后遇到 Failed to start mongod.service: Unit not found 请参考文章

  1. 安装Python
# For Ubuntu/Deepin etc.
apt-get install python3
  1. 安装库依赖 有关虚拟环境内容, 自行 Google Virtualenv pip install -r requirements.txt

常用的爬虫命令

  1. 爬取并输出csv文件 本项目默认输出 csv 文件, 关于输出的 pipeline 请参考 pipeline.py 中的相关类
scrapy crawl [spider_name] -o [doc_name].csv
  1. 爬取N页停止
scrapy crawl [spider_name] -s CLOSESPIDER_PAGECOUNT=[N]
  1. 爬取N项停止
scrapy crawl [spider_name] -s CLOSESPIDER_ITEMCOUNT=[N]
  1. 超时停止
scrapy crawl [spider_name] -s CLOSESPIDER_TIMEOUT=[N]

数据示例

请移步 data 文件夹. 仅供学习用途, 请勿商用.

LICENSE

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.