加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

反爬虫的必要措施!get到了就在也不担心反爬了!

发布时间:2020-12-17 01:21:13 所属栏目:Python 来源:网络整理
导读:p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88,88);font-family:'微软雅黑';"0×00 前言 p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';"0×01 介绍 p style="margin-

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88,88);font-family:'微软雅黑';">0×00 前言

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×01 介绍

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×02 问题的分类

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×03 顺从的艺术

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×04 反爬虫

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×05 Anti-Anti-Spider

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×06 爬虫编写注意事项

<p style="margin-bottom:0px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';">0×07 反馈与问题

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<h2 style="font-family:'微软雅黑';line-height:1.1;color:rgb(55,56,56);margin-top:30px;margin-bottom:15px;font-size:18px;background-color:rgb(255,255,255);">

<span style="color:rgb(0,176,80);"><p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,255);">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';background-color:rgb(255,255);">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,88);font-family:'微软雅黑';text-align:center;background-color:rgb(255,255);"><a href="https://image.3001.net/images/20160308/14574159528823.png" rel="nofollow" class="highslide-image" style="color:rgb(6,154,239);background:0px 0px;">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);">然后我们打开API页面的商品API页面:

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><a href="https://image.3001.net/images/20160308/14574156413956.png" rel="nofollow" class="highslide-image" style="color:rgb(6,239);background:0px 0px;">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);">我们发现它提供了不少易用的接口,开发者注册以后可以使用,或者处理一下丢给爬虫去使用。同样的淘宝也有相应的平台,但是应该是收费的,就是淘宝开放平台,要在聚石塔调用API才会生效:

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><a href="https://image.3001.net/images/20160308/14574156583556.png" rel="nofollow" class="highslide-image" style="color:rgb(6,239);background:0px 0px;">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><a href="https://image.3001.net/images/20160308/14574156609693.png" rel="nofollow" class="highslide-image" style="color:rgb(6,239);background:0px 0px;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<h3 style="font-family:'微软雅黑';line-height:1.1;color:rgb(0,112,192);margin-top:20px;margin-bottom:15px;font-size:16px;background-color:rgb(255,255);">2. User-Agent<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);">User-Agent是用户访问网站时候的浏览器的标识

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);">下面我列出了常见的几种正常的系统的User-Agent大家可以参考一下,

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><a href="https://image.3001.net/images/20160308/14574159967389.png" rel="nofollow" class="highslide-image" style="color:rgb(6,239);background:0px 0px;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<h3 style="font-family:'微软雅黑';line-height:1.1;color:rgb(0,255);">3、<span style="font-size:7pt;">?验证码反爬虫<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);">这个办法也是相当古老并且相当的有效果,如果一个爬虫要解释一个验证码中的内容,这在以前通过简单的图像识别是可以完成的,但是就现在来讲,验证码的干扰线,噪点都很多,甚至还出现了人类都难以认识的验证码(某二三零六)。

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><a href="https://image.3001.net/images/20160308/14574160358291.png" rel="nofollow" class="highslide-image" style="color:rgb(6,239);background:0px 0px;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

Clipboard Image.png

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><span style="font-weight:700;">接下来我们就讨论一些关于反爬虫反制的措施。其实在这段时间内,我总结出一条用于爬虫编写的核心定律:

<blockquote style="padding:10px 20px;margin-bottom:20px;font-size:14px;border-left-width:5px;border-left-style:solid;border-left-color:rgb(238,238,238);color:rgb(88,88);font-family:'微软雅黑';background:rgb(247,247,247);"><p style="margin-bottom:0px;max-width:100%;font-size:15px;">像一个人一样浏览网页,像一台机器一样分析数据

<p style="margin-bottom:10px;max-width:100%;font-size:15px;color:rgb(88,255);"><span style="font-weight:700;">接下来我们就讨论一下在整个一系列文章出现的解决方案能突破几种限制(Python2):

<blockquote style="padding:10px 20px;margin-bottom:20px;font-size:14px;border-left-width:5px;border-left-style:solid;border-left-color:rgb(238,247);"><p style="margin-bottom:10px;max-width:100%;font-size:15px;">1. Urllib是最弱的web网页浏览模式,User-Agent,cookie,ip都无法解决;

<p style="margin-bottom:10px;max-width:100%;font-size:15px;">2. Requests模块与urllib2,urllib3,基本可以解决静态网页的所有问题,但是没办法解决IP限制,如果需要解决IP限制则需要使用代理,如果需要解决验证码问题,则需要自己配置OCR;

<p style="margin-bottom:10px;max-width:100%;font-size:15px;">3. Selenium+浏览器:无法解决验证码的问题,效率低,速度慢;

<p style="margin-bottom:0px;max-width:100%;font-size:15px;">4. Ghost.py无法解决验证码问题,效率低,速度慢。

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">

<p style="margin-top:5px;margin-bottom:5px;max-width:100%;color:rgb(0,0);font-family:sans-serif;">


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读