我正在尝试使用以下URL执行请求GET:https://www.whoscored.com/Matches/1394177/Preview/Spain-LaLiga-2019-2020-Barcelona-Villarreal
当我使用Postman时,一切工作正常,但是一旦尝试使用python库Request,我会收到403-禁止此消息:
<iframe frameborder="0" height="100%" id="main-iframe" marginheight="0px" marginwidth="0px" src="/_Incapsula_Resource?CWUDNSAI=22&xinfo=9-128015709-0%200NNN%20RT%281569365075496%2067%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B15%284%2c200%2c0%29%20U18&incident_id=549001620109377666-353438150223530537&edet=15&cinfo=04000000" width="100%">
Request unsuccessful. Incapsula incident ID: 549001620109377666-353438150223530537
</iframe>
这是我的python代码:
url = 'https://www.whoscored.com/Matches/1394177/Preview/Spain-LaLiga-2019-2020-Barcelona-Villarreal'
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) '
'AppleWebKit/537.11 (KHTML, like Gecko) '
'Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive'
}
with requests.Session() as session:
response = session.get(url, headers=headers)
以下是邮递员请求的屏幕截图:https://ibb.co/PxkjkfS
如果您有任何想法,为什么我的请求而不是Postan会出现此问题,或者您有其他选择,请告诉我。
谢谢