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: /