我正在尝试登录https://ahrefs.com/user/login。在浏览器中一切正常,但它使用python显示网页“维护中”。有人能告诉我该怎么做才能登录吗?我的代码:
from requests import Session
data = {'email': 'email', 'password': 'pwd'}
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'ru,en-US;q=0.8,en;q=0.6,uk;q=0.4',
'dnt': '1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
}
s = Session()
r = s.get('https://ahrefs.com', headers=headers)
r = s.post('https://ahrefs.com/user/login', data=data, headers=headers)
print(r.text)
这是我使用此代码获得的网页:
<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8" />
<title>Updating the service - Ahrefs</title>
<meta name="description" content="We are currently updating our service and adding some cool new features!" >
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css">
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,100italic,100,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<link href="/assets/css/static.css?170317" media="screen" type="text/css" rel="stylesheet">
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png" >
<link rel="apple-touch-icon" sizes="76x76" href="/images/apple-touch-icon-76.png" >
<link rel="apple-touch-icon" sizes="120x120" href="/images/touch-icon-iphone-retina.png" >
<script type="text/javascript">
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.1.0";
analytics.load('Zg9CNakKRAv2PeY9l2SBX7XsvcyF4GoH');
analytics.page('500');
}}();
</script>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-28303106-1', 'ahrefs.com');
ga('require', 'displayfeatures');
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga('linker:autoLink', ['fastspring.com']);
ga('send', 'pageview');
</script>
</head>
<body class="page-error">
<header class="page__notfound">
<nav class="navbar no-radius navbar-ahrefs-header">
<a class="logo navbar-brand" href="/dashboard">Ahrefs</a>
</nav>
</header>
<article class="page__notfound__center container text-xs-center static-wrapper">
<div class="page__notfound__center--content">
<div class="page__notfound__error--img text-xs-center">
<img class="img-fluid" src="/images/service/robot-maintenance.png" alt="Updating service" />
</div>
<h1 class="page__notfound__title">Page under maintenance</h1>
<p class="page__notfound__text">We are currently updating our service and adding some cool new features.
<br>We will be back shortly. Thank you for your patience.
<span class="clearfix"></span>
<a href="javascript:window.location.href=window.location.href" class="page__notfound__link btn btn-secondary btn-ahrefs-sm"><span class="reload-icon"></span> Try again</a>
</p>
</div>
</article>
<script>
window.intercomSettings = {
app_id: "dic5omcp"
};
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/dic5omcp';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
</script>
<!-- end of intercom IO code -->
</body>
</html>