01. Introduction to crawler basics

Foreplay:

  1. Are you in the dead of night and want to see some pictures that will make you more awake but suffer from lack of resources...
  2. Do you want to quickly rush to buy train tickets successfully during the peak travel period on holidays...
  3. Do you want to quickly and accurately locate products with the best reputation and quality when you are shopping online...

What is a crawler:

- 通过编写程序,模拟浏览器上网,然后让其去互联网上抓取数据的过程。

The value of crawlers:

  1. Practical application
  2. Employment

Are reptiles legal or illegal?

  1. Is not prohibited by law
  2. Risk of illegality
  3. Good reptiles malicious reptiles

The risks brought by crawlers can be reflected in the following two aspects:

- 爬虫干扰了被访问网站的正常运营
- 爬虫抓取了收到法律保护的特定类型的数据或信息

How to avoid the bad luck of entering the game in the process of using and writing crawlers?

- 时常的优化自己的程序,避免干扰被访问网站的正常运行
- 在使用,传播爬取到的数据时,审查抓取到的内容,如果发现了涉及到用户隐私
商业机密等敏感内容需要及时停止爬取或传播

Classification of crawlers in usage scenarios

- 通用爬虫:
    抓取系统重要组成部分。抓取的是一整张页面数据。
- 聚焦爬虫:
    是建立在通用爬虫的基础之上。抓取的是页面中特定的局部内容。
- 增量式爬虫:
    检测网站中数据更新的情况。只会抓取网站中最新更新出来的数据。

Reptile sword shield

Anti-crawling mechanism
Portal websites can prevent crawlers from crawling website data by formulating corresponding strategies or technical means.

Anti-anti-climbing strategy
Crawler programs can crack the anti-climbing mechanism in the portal website by formulating relevant strategies or technical means, so as to obtain relevant data in the portal website.

robots.txt agreement:
gentleman agreement. It specifies which data in the website can be crawled by crawlers and which data cannot be crawled.

http protocol

- 概念:就是服务器和客户端进行数据交互的一种形式。

Common request header information
-User-Agent: The identity of the request carrier
-Connection: After the request is completed, whether to disconnect or keep the connection

Common response header information
-Content-Type: the type of data the server responds back to the client

https protocol:
-secure hypertext transfer protocol

Encryption method
-symmetric secret key encryption
-asymmetric secret key encryption
-certificate secret key encryption

Next: Detailed explanation of requests module

Guess you like

Origin blog.csdn.net/qq_40837794/article/details/109560445