当前位置:网站首页>反爬虫策略(ip代理、设置随机休眠时间、哔哩哔哩视频信息爬取、真实URL的获取、特殊字符的处理、时间戳的处理、多线程处理)
反爬虫策略(ip代理、设置随机休眠时间、哔哩哔哩视频信息爬取、真实URL的获取、特殊字符的处理、时间戳的处理、多线程处理)
2022-06-13 01:56:00 【Triumph19】
常见的反爬虫策略
1.通过Headers反爬虫
- 通过识别用户请求的Headers来反爬虫是网站最常用的反爬虫策略。很多网站都会对HTTP请求头部的User-Agent进行检测(判断是否为浏览器访问);有一部分网站会对Refer进行检测(一些资源网站的防盗链接);还有一部分会对Cookie进行检测(需要登录才能获取更多数据)。
2.基于用户行为反爬虫
- 通过检测用户行为来判断请求是否来自爬虫程序也是一种常用的反爬虫策略。例如,同一IP地址短时间内多次访问,或者同一账户短时间内多次进行相同操作,都有可能使网站采取反爬虫措施。
3.采用动态加载数据反爬虫
- 有一些网站的网页是通过JavaScript动态生成的,无法直接爬取当前网页获取所需数据,这样对爬虫程序的直接爬取造成了一些困难。
应对反爬虫的措施
1.使用代理IP
- 针对网站检测IP访问的反爬虫策略,可以使用代理IP。代理IP是代理用户取得网络信息的IP地址,它可以帮助爬虫程序掩藏真实身份,突破IP访问的限制,隐藏爬虫程序的真实IP,从而避免被网站的反爬虫程序禁止。
- requests库实现使用代理IP非常方便,只需要构造一个代理IP的字典,然后在发送HTTP请求时,使用proxies参数添加代理IP的字典即可。如果需要使用多个代理IP,可将所有的代理IP字典构成列表,然后从列表中随机选择代理IP。
边栏推荐
- 开发者来稿|AMD赛灵思中文论坛分享 - 提问的智慧
- rsync 傳輸排除目錄
- Read routing table
- Delphi 10.4.2 release instructions and installation methods of three patches
- 三、上传织物图片至SQL Server并提供name进行展示织物照片
- How does Google's audience work?
- JSON and protobuf Any interchange
- 五、库存查询功能的完善
- Why is "iFLYTEK Super Brain 2030 plan" more worthy of expectation than "pure" virtual human
- Numpy multidimensional array transpose transpose
猜你喜欢

Ten thousand words make it clear that synchronized and reentrantlock implement locks in concurrency

DFS and BFS to solve Treasure Island exploration

Machine learning basic SVM (support vector machine)

Establishment of microservice development environment

What is solid angle

dfs与bfs解决宝岛探险

华为设备配置双反射器优化虚拟专用网骨干层

Alertwindowmanager pop up prompt window help (Part 1)

Server installation jupyterab and remote login configuration
![[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] GPIO and register](/img/eb/9bd411be74937371de0bbf3f04267e.jpg)
[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] GPIO and register
随机推荐
Machine learning basic SVM (support vector machine)
[official document summary] writing standards for academic dissertations of National University of science and technology
Numpy multidimensional array transpose transpose
一、搭建django自动化平台(实现一键执行sql)
What is the path field—— Competitive advertising
Examples of using the chromium base library
Pyflink implements custom sourcefunction
Unity jsonutility failed to serialize list
六、出库管理功能的实现
Workspace for ROS
DFS and BFS to solve Treasure Island exploration
What is Google plus large text ads? How to use it?
Audiences with similar interests
When AI meets music, iFLYTEK music leads the industry reform with technology
rsync 传输排除目录
指针链表的实现
matplotlib画图中文乱码
如何解决通过new Date()获取时间写出数据库与当前时间相差8小时问题【亲测有效】
Plumber game
如何利用您的自有数据来实现营销目标?