当我向网站发送帖子请求时,我不断收到错误响应416。然后,当我检查HTML文本时,我得到:
<!DOCTYPE html>
<html>
<head>
<noscript>
<title>Pardon Our Interruption</title>
</noscript>
<meta name="viewport" content="width=1000">
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<style>
.container { max-width: 800px; margin: auto; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; color: #7a838c; }
h1 { color: #2a2d30; font-weight: 500; }
li { margin: 0 0 10px; }
a { color: #428bca; }
a:hover, a:focus { color: #2a6496; }
</style>
<script>
function showBlockPage() {
document.title = "Pardon Our Interruption"
document.getElementsByClassName("container")[0].style.display = "block";
}
setTimeout(showBlockPage, 10000);
</script>
<script type="text/javascript" src="/static/dc/init.js" async defer></script>
<script>window.addEventListener('load', showBlockPage)</script>
</head>
<body>
<div class="container">
<script>document.getElementsByClassName("container")[0].style.display = "none";</script>
<h1>Pardon Our Interruption</h1>
<p>As you were browsing something about your browser made us think you were a bot. There are a few reasons this might happen:</p>
<ul>
<noscript><li>You've disabled JavaScript in your web browser.</li></noscript>
<li>You're a power user moving through this website with super-human speed.</li>
<li>You've disabled cookies in your web browser.</li>
<li>A third-party browser plugin, such as Ghostery or NoScript, is preventing JavaScript from running. Additional information is available in this <a title='Third party browser plugins that block javascript' href='http://ds.tl/help-third-party-plugins' target='_blank'>support article</a>.</li>
</ul>
</div>
</body>
</html>
我真的不知道为什么发生这种情况。我知道错误416是字节未得到满足或类似的问题。但是我不知道为什么当我看到帖子请求的HTML时会说另一个错误。请帮忙。谢谢!
这是我的代码:
def login(self):
#1
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'max-age=0',
'referer': 'https://launches.endclothing.com/distil_r_drop.html',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'
}
page = self.scraper.get(
'https://www.endclothing.com/us/',
headers=headers
)
print(page)
#2
post = self.scraper.post(
'https://api2.endclothing.com/us/rest/V1/customers/isEmailAvailable',
headers={
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'application/json;charset=UTF-8',
'origin': 'https://www.endclothing.com',
'referer': 'https://www.endclothing.com/us/',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'
},
data={
'customerEmail': "xxx@yahoo.com"
}
)
print(post)