Giter Club home page Giter Club logo

taobao_spider's Introduction

基于Scrapy的Python3分布式淘宝爬虫

  • Items.py : 定义爬取的数据
  • pipelines.py : 后处理(Post-process),存储爬取的数据
  • taobao.py : 爬虫程序
  • settings.py : Srapy设定,请参考 内置设定参考手册
  • 代码的详细分析在我的个人博客 www.liangtianming.com
  • 问题和讨论可以发到我的邮箱 [email protected]
  • 不定期更新
  • 2017.7.23

实现功能:

输入关键字和搜索页数,获取在淘宝上搜索结果中所有商品的标题链接原价现价商家地址以及评论数量,并将数据存入MongoDB数据库

使用教程:

1. 运行前你需要安装并配置好环境:

  • Python3
  • Scrapy
  • MongoDB
  • redis

2. 打开MongoDB和redis服务

3. 下载并解压,把文件夹名改为taobao_spider

4. 打开多个cmd,把路径都切换到taobao_spider目录下,输入 scrapy crawl taobao --nolog

C:\Users>f:

F:\>cd taobao_spider

F:\taobao_spider>scrapy crawl taobao --nolog

5. 打开cmd,把路径切换到redis目录下,提交start_url

C:\Users>d:

D:\>cd redis

D:\Redis>redis-cli

127.0.0.1:6379> LPUSH TaobaoSpider:start_urls http://taobao.com/

6. 在终端中可看见爬取过程,数据存储在MangoDB的tbdb库的taobao表中(存储位置可在pipelines.py中修改)

7. 程序结束后,清除redis中的缓存

127.0.0.1:6379> flushdb

下面是一些爬取结果示例

  • 单个终端:

  • 多个终端:

  • 数据库:

taobao_spider's People

Contributors

tmliang avatar

Watchers

MrYing 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.