当前位置:网站首页>反爬虫的重点:识别爬虫
反爬虫的重点:识别爬虫
2022-07-07 17:02:00 【华为云】
我们在网站运营的时候,最大的问题就是:我们自己花费几个小时甚至是几天辛辛苦苦创作作的内容,被爬虫只需要 1s 就抓去了。为了保卫我们创作的成果,也为了网站的稳定运行,我们需要对爬虫说:No,我们在反爬虫的过程中最重要的就是如何识别爬虫。
为了识别识别爬虫,常用的有以下几个方法:
真人检测
所谓的真人检测也就是出现一个验证码,让你输入验证码的内容,这些验证码对于人类来说很容易识别,但是对于机器来说却很难识别,例如这种验证码:
这种验证码只有人类很轻易识别,爬虫却很难识别。
滑块类验证码
这里验证码对于人类来说也很友好,我们只需要将滑块移到一个阴影的位置,例如下面这种:
这类验证码对于人来来说轻而易举,但是对于爬虫来说有一定难度,但是也是可以破解的。
这些在一些特殊场合的确是可以防止爬虫对于你创作内容的抓取,但是你成功的防止了恶意爬虫,也成功的防止了搜索引擎爬虫来抓取你的内容。
我们为什么要允许搜索引擎爬虫来抓取我们的内容?
这个主要是由于搜索引擎可以给我带来流量,有了流量我们就可以想办法变现,有没有嗅到金钱的味道。
例如我们在百度搜索:爬虫识别,并点击了我的网站,就有访客访问网站,就给网站带来了流量。
那百度怎么知道我们网站上有什么内容呢?
百度搜索引擎每天有成千上万的爬虫在互联网上抓取内容,并将百度爬虫抓取的内容存入自己的索引之中,在根据一定的算法为每个网页排名,之后用户搜索相应的关键词之后,有可能会到达你网站,就会给你带来流量。
这就是为什么我们不能屏蔽搜索引擎爬虫的原因了,如果你像屏蔽其他爬虫一样屏蔽搜索引擎爬虫,那么搜索引擎爬虫将无法抓取你网站的内容,就不会在搜索结果中展示你的网站,也不会为你带来任何流量。
那现在有一个问题就是,我们既要屏蔽一些恶意爬虫,又不能屏蔽搜索引擎爬虫,我真的好难呀!
为了解决这个问题,我们可以使用爬虫识别这个网站来解决上面的问题。
首先我们需要根据 User-agent 先过滤掉一部分恶意爬虫,搜索引擎的 User-agent 我们可以在这里查看:搜索引擎爬虫
这里收集和整理了市面上大部分搜索引擎的 User-agent 与 IP 地址,例如下面是百度蜘蛛的 User-agent:
通过比对 User-agent 我们可以初步判断是不是搜索引擎的爬虫,但是 User-agent 是可以轻易伪造的,所以我们还需要配合 IP 来识别爬虫是否是真实的。
我们只需要到爬虫 IP 查询输入 IP 就可以知道这个是不是伪造爬虫了。
总结
这篇文章首先从验证码开始如何防止爬虫抓取我们网站,但是我们又不能屏蔽所有爬虫抓取我们网站,我们如何通过 User-agent 与 IP 结合的方式判断是搜索引擎爬虫,并让其抓取我们网站。
边栏推荐
- [Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question
- 【Unity Shader】插入Pass实现模型遮挡X光透视效果
- First time in China! The language AI strength of this Chinese enterprise is recognized as No.2 in the world! Second only to Google
- Datasimba launched wechat applet, and datanuza accepted the test of the whole scene| StartDT Hackathon
- Learn open62541 -- [67] add custom enum and display name
- 虚拟数字人里的生意经
- Reinforcement learning - learning notes 8 | Q-learning
- 2022年推荐免费在线接收短信平台(国内、国外)
- 前首富,沉迷种田
- Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
猜你喜欢
直播预约通道开启!解锁音视频应用快速上线的秘诀
数据验证框架 Apache BVal 再使用
RISCV64
单臂路由和三层交换的简单配置
Borui data was selected in the 2022 love analysis - Panoramic report of it operation and maintenance manufacturers
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
Nat address translation
Complete e-commerce system
Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
RIP和OSPF的区别和配置命令
随机推荐
[Base64 notes] [suggestions collection]
[software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered
Do you know all four common cache modes?
Industry case | digital operation base helps the transformation of life insurance industry
Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
国内首次!这家中国企业的语言AI实力被公认全球No.2!仅次于谷歌
Teach your sister to write the message queue hand in hand
Reinforcement learning - learning notes 8 | Q-learning
咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
SD_ DATA_ SEND_ SHIFT_ REGISTER
PTA 1102 teaching Super Champion volume
前首富,沉迷种田
初识缓存以及ehcache初体验「建议收藏」
【Unity Shader】插入Pass实现模型遮挡X光透视效果
IP netns command (memo)
50亿,福建又诞生一只母基金
Datasimba launched wechat applet, and datanuza accepted the test of the whole scene| StartDT Hackathon
Thread factory in thread pool
Nat address translation
Comparison and selection of kubernetes Devops CD Tools