GithubHelp home page GithubHelp logo

lx1025 / wechat_spider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lqqyt2423/wechat_spider

0.0 2.0 0.0 11.22 MB

微信文章爬虫,获取阅读量、点赞量、评论等

License: MIT License

JavaScript 98.87% HTML 0.86% CSS 0.27%

wechat_spider's Introduction

wechat_spider 微信爬虫

基于Node 的微信爬虫,通过中间人代理的原理,批量获取微信文章数据,包括阅读量、点赞量和评论等数据。

使用代理模块AnyProxy。代码已支持AnyProxy 4版本。

开始

安装前准备

  • 安装Node,版本大于 8.8.1
  • 安装MongoDB,版本大于 3.4.6
  • 安装Redis
  • 安装Node 全局模块nodemon 和pm2

安装

git clone https://github.com/lqqyt2423/wechat_spider.git
cd wechat_spider
npm install

本项目基于代理模块AnyProxy,解析微信HTTPS 请求需在电脑和手机上都安装证书。可参考:AnyProxy 文档

使用

cd wechat_spider
npm start
  1. 确保电脑和手机连接同一WIFI ,npm start 之后,命令行输出请配置代理: xx.xx.xx.xx:8101 类似语句,手机设置代理为此IP 和端口
  2. 手机上测试打开任一公众号历史文章详情页和文章页,观察电脑命令行的输出,查看数据是否保存至MongoDB
  3. 自动翻页抓取数据需配置config.js

自定义配置

目前可支持的配置项举例如下:

  • 控制是否开启文章或历史详情页自动跳转
  • 控制跳转时间间隔
  • 根据文章发布时间控制抓取范围
  • 是否保存文章正文内容
  • 是否保存文章评论

可编辑index.jsconfig.jstargetBiz.json 进行自定义配置。文件中注释有详细说明。

可视化界面

前端页面已打包好,启动项目后,如无修改默认server port 配置,浏览器直接访问http://localhost:8104 即可。检测数据有无抓取保存直接刷新此页面即可。

可视化界面

前端页面由React 编写,如需修改,可编辑client 文件中的代码。

MongoDB 数据信息

数据库database: wechat_spider

数据表collections:

  • posts - 文章数据
  • profiles - 公众号数据
  • comments - 评论数据
  • categories - 自定义的公众号分类

从MongoDB 导出数据

mongoexport --db wechat_spider --collection posts --type=csv --fields title,link,publishAt,readNum,likeNum,msgBiz,msgMid,msgIdx,sourceUrl,cover,digest,isFail --out ~/Desktop/posts.csv

以上命令会导出数据至桌面的posts.csv 中。具体的个性化导出请参考MongoDB 文档或者自己编写。

License

MIT

wechat_spider's People

Contributors

lqqyt2423 avatar

Watchers

James Cloos avatar  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.