基于搜狗微信搜索的微信公众号爬虫接口
===
[![Build Status](https://travis-ci.org/Chyroc/WechatSogou.svg?branch=master)](https://github.com/Chyroc/WechatSogou)
[![PyPI version](https://badge.fury.io/py/wechatsogou.svg)](https://github.com/Chyroc/WechatSogou)
[![PyPI](https://img.shields.io/pypi/wheel/wechatsogou.svg)](https://github.com/Chyroc/WechatSogou)
[![py27,py35,py36](https://img.shields.io/pypi/pyversions/wechatsogou.svg)](https://github.com/Chyroc/WechatSogou)
[![PyPI](https://img.shields.io/pypi/l/wechatsogou.svg)](https://github.com/Chyroc/WechatSogou)
我的另外一个作品: https://github.com/chyroc/lark ,基于代码生成的 Lark/飞书 Go SDK,欢迎 star 。
![ws_api.get_gzh_info('南航青年志愿者')](https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/get_gzh_info.png)
```
__ __ _ _ ____
\ \ / /__ ___| |__ __ _| |_/ ___| ___ __ _ ___ _ _
\ \ /\ / / _ \/ __| '_ \ / _` | __\___ \ / _ \ / _` |/ _ \| | | |
\ V V / __/ (__| | | | (_| | |_ ___) | (_) | (_| | (_) | |_| |
\_/\_/ \___|\___|_| |_|\__,_|\__|____/ \___/ \__, |\___/ \__,_|
|___/
```
# 项目简介
基于搜狗微信搜索的微信公众号爬虫接口,可以扩展成基于搜狗搜索的爬虫
如果有问题,请提issue
[CHANGELOG](./CHANGELOG.md)
# 交流分享
- QQ群(只需加一个)
- 一群 132955136(已满)
- 二群 819084985
- 微信群
# 赞助作者
甲鱼说,咖啡是灵魂的饮料,买点咖啡
[谢谢这些人的☕️](./coffee.md)
支付宝扫码大家一起领红包:
<img src="https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/alipay_hongbao.png" width="250" />
或者直接转账:
<img src="https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/pay_wechat.jpg" width="250" /><img src="https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/pay_ali.jpg" width="250" />
# 问题集锦
Q:没有得到原始文章url / 提示链接已经过期?
A:微信屏蔽此接口,请在临时链接有效期内保存文章内容。
Q:获取文章只能10篇?
A:是的,仅显示最近10条群发。
Q:使用的是python 2 还是 3?
A:都支持,若出错,请报BUG。
# 安装
```
pip install wechatsogou --upgrade
```
# 使用
### 初始化 API
```python
import wechatsogou
# 可配置参数
# 直连
ws_api = wechatsogou.WechatSogouAPI()
# 验证码输入错误的重试次数,默认为1
ws_api = wechatsogou.WechatSogouAPI(captcha_break_time=3)
# 所有requests库的参数都能在这用
# 如 配置代理,代理列表中至少需包含1个 HTTPS 协议的代理, 并确保代理可用
ws_api = wechatsogou.WechatSogouAPI(proxies={
"http": "127.0.0.1:8888",
"https": "127.0.0.1:8888",
})
# 如 设置超时
ws_api = wechatsogou.WechatSogouAPI(timeout=0.1)
```
### 获取特定公众号信息 - get_gzh_info
![ws_api.get_gzh_info('南航青年志愿者')](https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/get_gzh_info.png)
- 使用
```
In [5]: import wechatsogou
...:
...: ws_api =wechatsogou.WechatSogouAPI()
...: ws_api.get_gzh_info('南航青年志愿者')
...:
Out[5]:
{
'authentication': '南京航空航天大学',
'headimage': 'http://img01.sogoucdn.com/app/a/100520090/oIWsFt1tmWoG6vO6BcsS7St61bRE',
'introduction': '南航大志愿活动的领跑者,为你提供校内外的志愿资源和精彩消息.',
'post_perm': 26,
'view_perm': 1000,
'profile_url': 'http://mp.weixin.qq.com/profile?src=3×tamp=1501140102&ver=1&signature=OpcTZp20TUdKHjSqWh7m73RWBIzwYwINpib2ZktBkLG8NyHamTvK2jtzl7mf-VdpE246zXAq18GNm*S*bq4klw==',
'qrcode': 'http://mp.weixin.qq.com/rr?src=3×tamp=1501140102&ver=1&signature=-DnFampQflbiOadckRJaTaDRzGSNfisIfECELSo-lN-GeEOH8-XTtM*ASdavl0xuavw-bmAEQXOa1T39*EIsjzxz30LjyBNkjmgbT6bGnZM=',
'wechat_id': 'nanhangqinggong',
'wechat_name': '南航青年志愿者'
}
```
- 返回数据结构
```python
{
'profile_url': '', # 最近10条群发页链接
'headimage': '', # 头像
'wechat_name': '', # 名称
'wechat_id': '', # 微信id
'post_perm': int, # 最近一月群发数
'view_perm': int, # 最近一月阅读量
'qrcode': '', # 二维码
'introduction': '', # 简介
'authentication': '' # 认证
}
```
### 搜索公众号
![ws_api.search_gzh('南京航空航天大学')](https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/search_gzh.png)
- 使用
```
In [6]: import wechatsogou
...:
...: ws_api =wechatsogou.WechatSogouAPI()
...: ws_api.search_gzh('南京航空航天大学')
...:
Out[6]:
[
{
'authentication': '南京航空航天大学',
'headimage': 'http://img01.sogoucdn.com/app/a/100520090/oIWsFt1MvjqspMDVvZjpmxyo36sU',
'introduction': '南京航空航天大学官方微信',
'post_perm': 0,
'view_perm': 0,
'profile_url': 'http://mp.weixin.qq.com/profile?src=3×tamp=1501141990&ver=1&signature=S-7U131D3eQERC8yJGVAg2edySXn*qGVi5uE8QyQU034di*2mS6vGJVnQBRB0It9t9M-Qn7ynvjRKZNQrjBMEg==',
'qrcode': 'http://mp.weixin.qq.com/rr?src=3×tamp=1501141990&ver=1&signature=Tlp-r0AaBRxtx3TuuyjdxmjiR4aEJY-hjh0kmtV6byVu3QIQYiMlJttJgGu0hwtZMZCCntdfaP5jD4JXipTwoGecAze8ycEF5KYZqtLSsNE=',
'wechat_id': 'NUAA_1952',
'wechat_name': '南京航空航天大学'
},
{
'authentication': '南京航空航天大学',
'headimage': 'http://img01.sogoucdn.com/app/a/100520090/oIWsFtwVmjdK_57vIKeMceGXF5BQ',
'introduction': '南京航空航天大学团委官方微信平台',
'post_perm': 0,
'view_perm': 0,
'profile_url': 'http://mp.weixin.qq.com/profile?src=3×tamp=1501141990&ver=1&signature=aXFQrSDOiZJHedlL7vtAkvFMckxBmubE9VGrVczTwS601bOIT5Nrr8Pcgs6bQ-oEd6jdQ0aK5WCQjNwMAhJnyQ==',
'qrcode': 'http://mp.weixin.qq.com/rr?src=3×tamp=1501141990&ver=1&signature=7Cpbd9CVQsXJkExRcU5VM6NuyoxDQQfVfF7*CGI-PTR0y6stHPtdSDqzAzvPMWz67Xz9IMF2TDfu4Cndj5bKxlsFh6wGhiLH0b9ZKqgCW5k=',
'wechat_id': 'nuaa_tw',
'wechat_name': '南京航空航天大学团委'
},
...
]
```
- 数据结构
list of dict, dict:
```python
{
'profile_url': '', # 最近10条群发页链接
'headimage': '', # 头像
'wechat_name': '', # 名称
'wechat_id': '', # 微信id
'post_perm': int, # 最近一月群发数
'view_perm': int, # 最近一月阅读量
'qrcode': '', # 二维码
'introduction': '', # 介绍
'authentication': '' # 认证
}
```
### 搜索微信文章
![ws_api.search_article('南京航空航天大学')](https://raw.githubusercontent.com/chyroc/wechatsogou/master/screenshot/search_article.png)
- 使用
```
In [7]: import wechatsogou
...:
...: ws_api =wechatsogou.WechatSogouAPI()
...: ws_api.search_article('南京航空航天大学')
...:
Out[7]:
[
{
'article': {
'abstract': '【院校省份】江苏【报名时间】4月5日截止【考试时间】6月10日-11日南京航空航天大学2017年自主招生简章南京航空航天大学2017...',
'imgs': ['http://img01.sogoucdn.com/net/a/04/link?appid=100520033&url=http://mmbiz.qpic.cn/mmbiz_png/P07yicBRJfC71QB3lREx4J4x34QOibGaia5BkiaaiaiaibicWkTBULou9R08K6FaxlUA1RFBFWCmpO1Lepk7ZcXK45vguQ/0?wx_fmt=png'],
'time': 1490270644,
'title': '南京航空航天大学2017年自主招生简章',
'url': 'http://mp.weixin.qq.com/s?src=3×tamp=1501142580&ver=1&signature=hRMlQOLQpu4BNhBACavusZdmk**D65qHyz5LWDq1lPjVcm7*iiBS0l7Pq40h0fiCX*bZ8vSMLzAMDNzELYFKIQ7mND0-7cQi-N0BtfTBql*CQdsHun-GtaYEqRva6Ukwce3gZh46SXJzo90kyZ3dwVYl6*589bGDIzG6JTGfpxI='
},
'gzh': {
'headimage': 'http://wx.qlogo.cn/mmhead/Q3auHgzwzM5kiawibor6ABhnibMYnOADvqdcrl5XWiaFfM5mGYZ8cUica6A/0',
'isv': 0,
'profile_url': 'http://mp.weixin.qq.com/profile?src=3×tamp=1501142580&ver=1&signature=dVkDdcFr1suL1WHdCOJj7pwZhG9W*
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的工作流程包括以下几个关键步骤: URL收集: 爬虫从一个或多个初始URL开始,递归或迭代地发现新的URL,构建一个URL队列。这些URL可以通过链接分析、站点地图、搜索引擎等方式获取。 请求网页: 爬虫使用HTTP或其他协议向目标URL发起请求,获取网页的HTML内容。这通常通过HTTP请求库实现,如Python中的Requests库。 解析内容: 爬虫对获取的HTML进行解析,提取有用的信息。常用的解析工具有正则表达式、XPath、Beautiful Soup等。这些工具帮助爬虫定位和提取目标数据,如文本、图片、链接等。 数据存储: 爬虫将提取的数据存储到数据库、文件或其他存储介质中,以备后续分析或展示。常用的存储形式包括关系型数据库、NoSQL数据库、JSON文件等。 遵守规则: 为避免对网站造成过大负担或触发反爬虫机制,爬虫需要遵守网站的robots.txt协议,限制访问频率和深度,并模拟人类访问行为,如设置User-Agent。 反爬虫应对: 由于爬虫的存在,一些网站采取了反爬虫措施,如验证码、IP封锁等。爬虫工程师需要设计相应的策略来应对这些挑战。 爬虫在各个领域都有广泛的应用,包括搜索引擎索引、数据挖掘、价格监测、新闻聚合等。然而,使用爬虫需要遵守法律和伦理规范,尊重网站的使用政策,并确保对被访问网站的服务器负责。
资源推荐
资源详情
资源评论
收起资源包目录
基于搜狗微信搜索的微信公众号爬虫接口.zip (56个子文件)
SJT-code
.travis.yml 484B
setup.py 2KB
.gitattributes 65B
Makefile 836B
screenshot
search_article.png 307KB
pay_ali.jpg 103KB
get_gzh_article_by_history.png 336KB
get_sugg.png 105KB
alipay_hongbao.png 92KB
pay_wechat.jpg 101KB
get_gzh_article_by_hot.png 381KB
search_gzh.png 536KB
get_gzh_info.png 194KB
LICENSE 11KB
CHANGELOG.md 28KB
tox.ini 246B
docs
README.rst 16KB
HISTORY.rst 28KB
wechatsogou
filecache.py 513B
__init__.py 1KB
identify_image.py 3KB
request.py 6KB
five.py 969B
api.py 24KB
structuring.py 20KB
const.py 6KB
tools.py 3KB
exceptions.py 766B
requirements.txt 109B
test
__init__.py 474B
test_request_gen_search_gzh_url.py 986B
file
search-gaokao-article.json 42KB
article_detail_mpvoice.html 179KB
wapindex-wap-0612-wap_8-0.html 27KB
article_detail_backgroud-image.html 159KB
article_detail_qqmusic.html 95KB
search-gaokao-gzh.html 40KB
article_detail_expired.html 5KB
search-gaokao-article.html 46KB
bitsea-history.html 17KB
search-gaokao-gzh-error.html 5KB
article_detail_iframe.html 114KB
test_tools.py 2KB
test_const.py 3KB
test_request_gen_search_article_url.py 4KB
test_api.py 4KB
fateadm.py 1KB
test_structuring.py 28KB
rk.py 2KB
test_request_gen_hot_url.py 1KB
MANIFEST.in 27B
.gitignore 268B
setup.cfg 27B
README.md 15KB
mkdocs.yml 261B
coffee.md 158B
共 56 条
- 1
资源评论
JJJ69
- 粉丝: 6222
- 资源: 5780
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Pytorch训练CIRAR10上分类算法.zip
- Pytorch-pytorch深度学习教程之Tensorboard.zip
- 基于C++和Python开发yolov8-face作为人脸检测器dlib作为人脸识别器的人脸考勤系统源码+项目说明.zip
- Pytorch-pytorch深度学习教程之变分自动编码器.zip
- Pytorch-pytorch深度学习教程之神经风格迁移.zip
- Pytorch-pytorch深度学习教程之深度残差网络.zip
- Pytorch-pytorch深度学习教程之循环神经网络.zip
- Pytorch-pytorch深度学习教程之逻辑回归.zip
- Pytorch-pytorch深度学习教程之双向循环网络.zip
- Pytorch-pytorch深度学习教程之卷积神经网络.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功