Robots协议
约束性: Robots协议是建议但非约束性,网络爬虫可以不遵守,但存在法律风险。
网站排除爬虫有两个办法
审查来源
Robots协议告知
作用:网站告知网络爬虫哪些页面可以抓取,哪些不行。形式:在网站根目录下的robots.txt文件。
查看京东Robots协议
https://www.jd.com/robots.txt,
可以看到:(并不是所有网站都有协议,无Robots协议说明可任意爬取)
User-agent: * 无论什么样的爬虫都应当遵守如下协议
Disallow: /?* 任何爬虫都不当访问以问号开头的网站
Disallow: /pop/*.html
Disallow: /pinpai/*.html?*
User-agent: EtaoSpider 这个爬虫不允许爬取京东的任何资源
Disallow: /
User-agent: HuihuiSpider
Disallow: /
User-agent: GwdangSpider
Disallow: /
User-agent: WochachaSpider
Disallow: /