python - 如何用Python绕过Incapsula

标签 python scrapy recaptcha incapsula

我使用 Scrapy我试着抓取 this site使用 Incapsula

<meta name="robots" content="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=719d34d31c8e3a6e6fffd425f7e032f3">
</script>

我已经问过 Question关于这个问题 2 年前,但这种方法 ( Incapsula-Cracker ) 不再有效。

我试图理解 How Incapsula works 我试过这个绕过它

def start_requests(self):
    yield Request('https://courses-en-ligne.carrefour.fr',  cookies={'store': 92}, dont_filter=True, callback = self.init_shop)
def init_shop(self,response) :
    result_content      = response.body
    RE_ENCODED_FUNCTION = re.compile('var b="(.*?)"', re.DOTALL)
    RE_INCAPSULA        = re.compile('(_Incapsula_Resource\?SWHANEDL=.*?)"')
    INCAPSULA_URL       = 'https://courses-en-ligne.carrefour.fr/%s'
    encoded_func        = RE_ENCODED_FUNCTION.search(result_content).group(1)
    decoded_func        = ''.join([chr(int(encoded_func[i:i+2], 16)) for i in xrange(0, len(encoded_func), 2)])
    incapsula_params    = RE_INCAPSULA.search(decoded_func).group(1)
    incap_url           = INCAPSULA_URL % incapsula_params
    yield Request(incap_url)
def parse(self):
    print response.body 

但我被重定向到 RE-Captcha Page

<html style="height:100%">
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body style="margin:0px;height:100%">
<iframe src="/_Incapsula_Resource?CWUDNSAI=27&xinfo=3-10784678-0%200NNN%20RT%281523525225370%20394%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B12%284%2c316%2c0%29%20U10000&incident_id=459000960022408474-41333502566401539&edet=12&cinfo=04000000" frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula incident ID: 459000960022408474-41333502566401539
</iframe>
</body>
</html>

最佳答案

所以首先,对于此类问题没有万无一失的解决方案。作为一名实际用户,我最终不得不在 StackOverflow 上回答问题时解决验证码问题。这意味着机器人肯定会获得验证码。

现在我尝试并遵循一些规则来减少验证码的机会

  • 切勿为此类项目使用共享代理。使用 TOR 是一个很大的NO
  • 使用 Chrome + Selenium + Proxy
  • 通过现有配置文件 使用 Chrome。我更喜欢拥有不同网站的浏览历史记录、来自许多其他网站和跟踪器的 cookie 以及回溯月份的配置文件。您不知道如何评估用户/机器人差异。所以你想看起来更像一个真正的用户
  • 切勿快速抓取,尽可能多地使用延迟和尽可能随机的延迟
  • 始终使用可见的浏览器并持续监控验证码,在验证码出现时手动解决验证码或使用 DeathByCaptcha 或类似服务。尽量不要中止验证码页面,因为它可能会将您的机器人概率检查提高到更高等级

这是一场猫捉老鼠的游戏,你不知道对方有什么防御手段。所以你试着玩得轻松愉快

关于python - 如何用Python绕过Incapsula,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49751135/

相关文章:

python - 二维 numpy 数组中具有重复第一个元素的平均条目

python - 如何通过正则表达式查找某些字符串,但当特殊字符串不相邻时?

python - Scrapy DOWNLOAD_DELAY 不适用于顺序请求

python - 下载器中间件忽略对 scrapy 中某个 URL 的所有请求

python - 未使用 Flask-WTForms 设置 RECAPTCHA_PUBLIC_KEY 配置

Python:使用 BeautifulSoup 解析 anchor 文本

python - 试图找到第 1000 个质数

python - Scrapy编程错误: Not all parameters were used in the SQL statement

recaptcha - 不再有 recapcha 全局 key 选项吗?

ruby - 如何解决 Rails 3 中的 RecaptchaError?