Coder Social home page Coder Social logo

cw1997 / tieba-birthday-spider Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 8.0 19 KB

百度贴吧生日爬虫,可抓取贴吧内吧友生日,并且在对应日期自动发送祝福

License: Apache License 2.0

Python 100.00%
python threading queue mongodb tieba spider birthday post config pymongo

tieba-birthday-spider's Introduction

Tieba-Birthday-Spider

百度贴吧生日爬虫,可抓取贴吧内吧友生日,并且在对应日期自动发送祝福

更新日志

  • Version 0.1.0 (2017-06-13 16:00:30) 首次提交代码

执行环境

Python 2.7 64bit + MongoDB (请确保环境为64位,防止爬虫中的queue容量过大导致在32位环境下内存不足的异常发生)

项目依赖包

  • pymongo
  • BeautifulSoup
  • requests

使用方法

  1. 使用pip或者其他方式正确安装好上述项目依赖包
  2. 启动MongoDB
  3. 配置config.py中各项参数
  4. 启动spider.py进行生日等数据抓取
  5. 运行post.py测试是否能正常发送生日祝福贴
  6. 配置cron规则,让post.py能够每天定时运行,并且保证MongoDB服务一直保持开启状态

文件说明

文件名称 文件说明 备注
config.py 配置信息 内部附有注释,请正确配置。 如果有任何问题或者认为注释有描述不清需要改进的地方欢迎提issue与我讨论。为了防止频繁发帖导致您的百度帐号被误判为SPAM而封号,请尽可能注册几个小号,并且升级到合适的等级以防出现验证码。后期我们会考虑增加接入打码平台。
spider.py 爬虫主文件 在config.py中正确配置好相关参数后,先启动MongoDB服务,然后可直接执行该文件 ,抓取的信息将直接存储在MongoDB中。
post.py 定时发帖主文件 执行该文件将会自动按照配置文件中设置好的参数,将会将指定贴吧内所有过生日的吧友信息提取出来,并且向指定帖子中发送生日祝福。如果需要定时发送,请将该文件加入cron规则,crontab规则:0 0 0 * *表示在每日0点0分0秒自动执行该脚本。并且保证MongoDB服务一直保持开启状态。 如果需要自定义祝福帖内容模版,请参照main函数中的buildContent函数调用点以及相关注释自行修改post.py下的buildContent函数。
TiebaSpider.py 部分贴吧信息抓取方法 默认使用内置的html_parser作为BeautifulSouphtml_parser,用户可以自行修改TiebaSpider类的属性成员html_parser来使用其他html_parser,比如说html5lib。该类使用requests模块进行http通信。
TiebaUtil.py 部分贴吧发帖回帖以及登录检测模块 该类使用urllib2模块进行http通信。
SpiderUtil.py 爬虫助手函数 用于整理抓取到的信息,或者获取一些特殊元数据。

程序特点

  • 使用threading多线程库+Queue队列,性能高效
  • MongoDB持久化存储爬虫内容,适合抓取内容结构随时可变的场景

成功案例

交流QQ群

tieba-birthday-spider's People

Contributors

cw1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tieba-birthday-spider's Issues

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.