爬虫的基本分类和爬虫的流程

1 爬虫的分类

根据被爬网站的数量的不同,我们把爬虫分为:

  • 通用爬虫 :通常指搜索引擎的爬虫(https://www.baidu.com)

  • 聚焦爬虫 :针对特定网站的爬虫

2 爬虫的流程

爬虫的工作流程:


  • 向起始url发送请求,并获取响应
  • 对响应进行提取
  • 如果提取url,则继续发送请求获取响应
  • 如果提取数据,则将数据进行保存

3 robots协议

Robots协议:网站通过Robots协议告诉搜索引擎哪些页面可以抓取,哪些页面不能抓取,但它仅仅是互联网中的一般约定

https://www.taobao.com/robots.txt

User-agent:  Baiduspider
Allow:  /article
Allow:  /oshtml
Allow:  /ershou
Disallow:  /product/
Disallow:  /

User-Agent:  Googlebot
Allow:  /article
Allow:  /oshtml
Allow:  /product
Allow:  /spu
Allow:  /dianpu
Allow:  /oversea
Allow:  /list
Allow:  /ershou
Disallow:  /

User-agent:  Bingbot
Allow:  /article
Allow:  /oshtml
Allow:  /product
Allow:  /spu
Allow:  /dianpu
Allow:  /oversea
Allow:  /list
Allow:  /ershou
Disallow:  /

User-Agent:  360Spider
Allow:  /article
Allow:  /oshtml
Allow:  /ershou
Disallow:  /

User-Agent:  Yisouspider
Allow:  /article
Allow:  /oshtml
Allow:  /ershou
Disallow:  /

User-Agent:  Sogouspider
Allow:  /article
Allow:  /oshtml
Allow:  /product
Allow:  /ershou
Disallow:  /

User-Agent:  Yahoo!  Slurp
Allow:  /product
Allow:  /spu
Allow:  /dianpu
Allow:  /oversea
Allow:  /list
Allow:  /ershou
Disallow:  /

User-Agent:  *
Disallow:  /

猜你喜欢

转载自blog.csdn.net/qq_29286967/article/details/80993514
今日推荐