Code Monkey home page Code Monkey logo

awesome_crawl's Introduction

awesome_crawl Awesome


爬虫 说明 技术栈
腾讯新闻 采集所有腾讯新闻的链接和新闻详情 scrapy,mongo,redis
知乎话题 从话题广场出发,先采集子话题ID,再采集ID下所有问题 scrapy,mongo,redis
微博粉丝 采集大V的所有粉丝 scrapy,mongo,redis
Tumblr爬虫 下载指定Tumblr博主的资源 requests,concurrent
妹子图爬虫 go语言下载妹子图 goroutine,goquery

如果能帮助你,那就最好了。欢迎关注公众号:

采集策略

网站地图出发,找出所有子分类,从每个子分类中再寻找详情页面的链接。

首先寻找每条新闻的ID,然后移动端采集具体内容。

再去找一些推荐新闻的接口,做一个“泛爬虫”。

说明

整套系统中分为两部分,一套是生产者,专门去采集qq新闻的链接,然后存放到redis中,一套是消费者,从redis中读取这些链接,解析详情数据。 所有配置文件都是爬虫中的custom_settings中,可以自定义。

如果需要设置代理,请在middlewares.ProxyMiddleware中设置。

qq_list: 这个爬虫是生产者。运行之后,在你的redis服务器中会出现qq_detail:start_urls,即种子链接

qq_detail: 这个爬虫是生消费者,运行之后会消费redis里面的数据,如下图:

你可以自行添加更多爬虫去采集种子链接,如从首页进入匹配,从推荐入口:

import requests

url = "https://pacaio.match.qq.com/xw/recommend"

querystring = {"num":"10^","callback":"__jp0"}

headers = {
    'accept-encoding': "gzip, deflate, br",
    'accept-language': "zh-CN,zh;q=0.9,en;q=0.8",
    'user-agent': "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
    'accept': "*/*",
    'referer': "https://xw.qq.com/m/recommend/",
    'authority': "pacaio.match.qq.com",
    'cache-control': "no-cache",
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)

等等,你所需要做的仅仅是把这些抓到的种子链接塞到redis里面,也就是启用qq_news.pipelines.RedisStartUrlsPipeline这个中间件。

TODO

  1. 增加更多新闻链接的匹配,从推荐接口处获得更多种子链接
  2. 增加“泛爬虫”,采集种子链接
  3. 数据库字段检验
  4. redis中数据为空爬虫自动关闭(目前redis数据被消费完之后爬虫并不会自动关闭,如下图)

话题广场出发,先采集所有知乎的子话题,如

解析之后把所有的话题ID保存到redis中,再新建爬虫去采集该话题下所有的问题(这部分基本完工,但是还没测试过)。

详见 为了知道胡歌粉丝的男女比率,爬了三百万微博数据

filepath: tumblr_spider/tumblr_spider.py

useage: python tumblr_spider.py username example: python tumblr_spider.py user1,use2,use3

Attention: 你需要可以访问国外的代理,并在get_proxy()函数中设置

使用go开发的爬虫,可以下载妹子图至本地,效果如下:

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.