PyBot/开发文档/baidu开发文档.md

22 lines
925 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 设计思路
前情提要:百度搜索的爬取处理逻辑和搜狗-微信公众号的逻辑基本一致,但是百度搜索杂系数太大,存在大量不相关内容,所以使用百度的一个参数进行调整。
api地址
www.baidu.com/s?wd={关键词}&cl=3&pn=1&ie=utf-8&rn=20&tn=baidurt
- wd={关键词}:设置查询关键词
- cl=3查询类型3为网页2为图片默认为3
- pn=1指定查询页数
- rn=20每页显示数量
- ie=utf-8指定查询编码格式
- tn=baidurt设置为简化格式爬虫友好化
### 速率限制
建议设置高每页数量,减小搜索次数以规避反爬虫措施。
### 使用技术
- python-bs4网页解析
- python-sqlite联动
- python-request爬虫
- sqlite筛选
### 问题阐述
- 百度抓取的文章若是时间是近日,则不会显示具体时间,而是显示【*天前】,需要处理