Skip to content

微信公众号爬虫 (只需设置代理, 一键可以爬取所有历史文章)

Notifications You must be signed in to change notification settings

graceshare/wechat_spider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wechat_spider

微信公众号爬虫 (只需设置代理, 一键可以爬取指定公众号的所有历史文章)

package main

import (
	"log"
	"net/http"

	"github.com/sundy-li/wechat_spider"

	"github.com/elazarl/goproxy"
)

func main() {
	var port = "8899"
	proxy := goproxy.NewProxyHttpServer()
	//open it see detail logs
	// wechat.Verbose = true
	proxy.OnResponse().DoFunc(
		wechat_spider.ProxyHandle(wechat_spider.NewBaseProcessor()),
	)
	log.Println("server will at port:" + port)
	log.Fatal(http.ListenAndServe(":"+port, proxy))

}
  • 使用方法: 运行后, 设置手机的代理为 本机ip 8899端口, 打开微信客户端, 点击任一公众号查看历史文章按钮, 即可爬取该公众号的所有历史文章(已经支持自动翻页爬取)

  • 自定义输出源,实现Processor接口的Output方法即可, custom_output_server.go

  • 微信会屏蔽频繁的请求,所以历史文章的翻页请求调用了Sleep()方法, 默认每个请求休眠50ms,可以根据实际情况自定义Processor覆盖此方法

About

微信公众号爬虫 (只需设置代理, 一键可以爬取所有历史文章)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%