Code Monkey home page Code Monkey logo

fangspider's Introduction

买房/租房 爬虫

  • 可自定义小区黑名单(用于过滤掉商住两用房)
  • 每个抓取源需要自己更新下抓取的数据映射规则
  • 在fangspider/spiders/数据源.py里直接写符合抓取的页码条件的URL
  • 如果链家或者房天下的页面布局变化了可能要修改spiders里的匹配规则
  • 可以每小时跑一次,最后执行 python gen_summary.py -d 年-月-日 会汇总在Excel里
  • 可以修改配置来变更模拟浏览器访问的UserAgent

环境准备

Linux

sudo apt-get install python3 python3-dev
python -m pip install scrapy
python -m pip install openpyxl msgpack-python requests

sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev
pip install Scrapy 
pip install openpyxl msgpack-python requests

OSX

xcode-select --install

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

brew install python3
brew update; brew upgrade python3
python -m pip install scrapy
python -m pip install openpyxl msgpack-python requests

brew install python
brew update; brew upgrade python
pip install Scrapy
pip install openpyxl msgpack-python requests

Windows

Windows下只支持python2,并且要额外安装pywin32

c:\python27\python.exe c:\python27\tools\scripts\win_add2path.py
pip install Scrapy
pip install openpyxl msgpack-python requests

Anaconda

conda install -c conda-forge scrapy
conda install openpyxl msgpack-python requests

使用

# 查看数据源
scrapy list

# 抓取数据源
scrapy crawl 数据源名称

# 检查数据源
scrapy check [-l] 数据源名称

# 测试下载地址
scrapy fetch URL

# 生成某天的Excel数据表格
python gen_summary.py -d 年-月-日

配置

fangspider/settings.py

  • 必须配置抓取的房源的价格上限和下限
  • 最好配置城市名称,防止可能名称在多个城市中都有导致位置查询错误
  • GIS字段用于配置地理位置信息抓取的Key和路径规划的目标点

fangspider's People

Contributors

owent avatar

Watchers

 avatar

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.