Code Monkey home page Code Monkey logo

tumblrspider's Introduction

TumblrSpider

使用scrapy编写的python爬虫,爬取汤不热上用户发布的图片与视频,下载到本地。

avatar

项目结构

  • 爬虫:tbr.py

    1. 利用tumblr的一个接口:https://username.tumblr.com/api/read/json?start=0&num=200 获取用户post的内容。
    2. 获取用户post的视频或图片url。
    3. 若是reblogged的内容则将被转发的该用户加入爬取,可设置爬取深度。
  • 中间件: middlewares.py

    1. 设置代理,因为某种原因,不能直接上tumblr,所以需要科学上网后才行,ssr开全局模式后可以无需代理直接爬,若是PAC模式则需要添加本地代理。
    2. 也可以直接添加国外代理IP
  • items: items.py

    1. 三个字段,分别为file_url, file_pathfile_type
  • 下载管道: pipelines.py

    1. scrapy文件下载两种方式,用FilesPipeline或者requests。
    2. TumblrspiderPipeline 是用文件pipeline写的pipeline。
    3. MyFilesPipeline 是用requests方式写的pipeline。
    4. 相同网络环境下,前者比后者速度快,所以使用第一种pipeline就行。

项目依赖

  • scrapy
  • requests
  • ssr(或其他科学上网工具)

使用方法

  • 确保自己的电脑能够访问 https://www.tumblr.com/
  • ./tumblrSpider/tumblrSpider/spiders/tbr.py 文件中,在start_urls中填入一个种子用户的主页地址。max_depth 可设置最大爬取深度。
  • ./tumblrSpider 路径下, 使用命令 scrapy crawl tbr

tumblrspider's People

Contributors

ice-tong avatar pray3 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.