Code Monkey home page Code Monkey logo

wechat-spider-1's Introduction

爬取指定微信公众号的全部历史文章

用法:(目前需要手动获取 cookie 等验证信息)

  • STEP 1 配置两处验证信息:

    A. src/index.js 中的 key 值和 biz 值

    获取方法: 手机、电脑同时登录微信 -> 手机里搜索一个公众号 -> 进入公众号后点击右上角的人像按钮 -> 点击“查看历史消息” -> 点击右上角三个点 -> 分享给自己 -> 电脑端收到消息后点击 -> 浏览器打开历史消息页面后从 url 里即可找到 key 值和 biz 值

    B. src/headers.js 中的 Cookie 值

    获取方法: 电脑端浏览器打开历史消息页面后 -> 右键“检查” -> 刷新页面 -> network 选项卡里找到 https://mp.weixin.qq.com/mp/getmasssendmsg 请求 -> 在请求头里找到 Cookie 字段即可

  • STEP 2 运行脚本

    npm install
    npm run build
    node lib/index.js

随后,每条文章将以 .json 格式的文件存储到 output 目录下。

例:

{
  "id" : "503948740",
  "title" : "刚收养的杜宾犬使劲咬住小孩把她扔出去,走近看才发现原因……",
  "desc" : "Svilicic夫妇刚在4天前收养了一只名叫Khan的杜宾犬,之前的主人虐待过它最后还遗弃了它,收容所在这对",
  "url" : "http://mp.weixin.qq.com/s?__biz=MjM5NjM2NjQ0OA==&mid=2651432395&idx=4&sn=bee861bd2f1325e4a1103a8a8156f3e7&scene=4#wechat_redirect",
  "cover" : "http://mmbiz.qpic.cn/mmbiz/ftBdoTM0jjUicicfhMb8Wq2yibnAqibJQMBONzoCSprVUrgOWgTtFJmRK16kT6libkNFb4ib9ibKQH0mNTYG6yaIicEaibA/0?wx_fmt=jpeg",
}

wechat-spider-1's People

Contributors

jugg-yy avatar

Watchers

Bill Wang 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.