我正在为阿迪达斯的个人项目编写一个机器人,但我被阻止了。我该如何克服这一点?
我的代码:
import requests
url = 'https://www.adidas.com.tr/en/predator-edge.4-turf-boots/GX0010.html'
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
}
response = requests.get(url, headers=headers)
print(response.text)
”
我需要获取传入的页面并对其进行解析,但错误返回给我:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale = 1.0, maximum-scale=1.0, user-scalable=no" />
<title>adidas</title>
<link href="/WAFfailoverassets/style.css" rel="stylesheet"/>
</head>
<body>
<main class="content-wrapper">
<header class="top">
<div class="logo">adidas</div>
<span id="ctl00_mainContentPlaceHolder_lblInvalidRequest">
<br/> Reference Error: 18.a4e1202.1686570590.149c3b8a </span>
<h1 class="title">Unfortunately we are unable to give you access to our site at this time. </h1>
<p>A security issue was automatically identified, when you tried to access the website.</p>
</header>
<div class="columns">
<section class="column column-1">
<h3>What could have caused this?</h3>
<p>During high-traffic product releases we have extra security in place to prevent bots entering our site. We do this to protect customers and to give everyone a fair chance of getting the sneakers. Something in your setup must have triggered our security system, so we cannot allow you onto the site.</p>
</section>
.
.
.
1条答案
按热度按时间w7t8yxp51#
好吧,它看起来像是阿迪达斯可能只允许通过浏览器发出请求作为他们的机器人保护的一部分,因为你是通过python运行它的一个非常简单的请求,你已经被标记为一个机器人。你将需要欺骗阿迪达斯,你是一个合法的请求浏览器。希望这能回答你的问题。