File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -256,3 +256,45 @@ Scrapy是一个基于Twisted的开源的Python爬虫框架,在工业中应用
256256相关内容可以参考[ 基于Scrapy网络爬虫的搭建] ( http://www.lining0806.com/%E5%9F%BA%E4%BA%8Escrapy%E7%BD%91%E7%BB%9C%E7%88%AC%E8%99%AB%E7%9A%84%E6%90%AD%E5%BB%BA/ ) ,同时给出这篇文章介绍的[ 微信搜索] ( http://weixin.sogou.com/weixin ) 爬取的项目代码,给大家作为学习参考。
257257
258258参考项目:[ 使用Scrapy或Requests递归抓取微信搜索结果] ( https://github.com/lining0806/PythonSpiderNotes/blob/master/WechatSearchProjects )
259+
260+ ## Robots协议
261+
262+ 好的网络爬虫,首先需要遵守** Robots协议** 。Robots协议(也称为爬虫协议、机器人协议等)的全称是“网络爬虫排除标准”(Robots Exclusion Protocol),网站通过Robots协议告诉搜索引擎哪些页面可以抓取,哪些页面不能抓取。
263+
264+ 在网站根目录下放一个robots.txt文本文件(如 https://www.taobao.com/robots.txt ),里面可以指定不同的网络爬虫能访问的页面和禁止访问的页面,指定的页面由正则表达式表示。网络爬虫在采集这个网站之前,首先获取到这个robots.txt文本文件,然后解析到其中的规则,然后根据规则来采集网站的数据。
265+
266+ ### Robots协议规则
267+
268+ User-agent: 指定对哪些爬虫生效
269+ Disallow: 指定不允许访问的网址
270+ Allow: 指定允许访问的网址
271+ 注意: 一个英文要大写,冒号是英文状态下,冒号后面有一个空格,"/"代表整个网站
272+
273+ ### Robots协议举例
274+
275+ 禁止所有机器人访问
276+ User-agent: *
277+ Disallow: /
278+ 允许所有机器人访问
279+ User-agent: *
280+ Disallow:
281+ 禁止特定机器人访问
282+ User-agent: BadBot
283+ Disallow: /
284+ 允许特定机器人访问
285+ User-agent: GoodBot
286+ Disallow:
287+ 禁止访问特定目录
288+ User-agent: *
289+ Disallow: /images/
290+ 仅允许访问特定目录
291+ User-agent: *
292+ Allow: /images/
293+ Disallow: /
294+ 禁止访问特定文件
295+ User-agent: *
296+ Disallow: /*.html$
297+ 仅允许访问特定文件
298+ User-agent: *
299+ Allow: /*.html$
300+ Disallow: /
You can’t perform that action at this time.
0 commit comments