我正在发出浏览器正在发出的确切请求,但没有获得浏览器显示的ajax响应数据,而是获得了Refere链接的页面源内容(“ Referer”:“ https://homezz.ro/garsonera-bucuresti-noi-decomandata-1841433.html”) 。如何读取返回到浏览器的Ajax响应?
这里是链接“ https://homezz.ro/garsonera-bucuresti-noi-decomandata-1841433.html”,当我们“单击显示电话号码”时,进行了ajax调用,该电话返回了电话号码数据,我需要通过复制该ajax调用来提取该数据。
header={
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9,ur-PK;q=0.8,ur;q=0.7',
'Connection': 'keep-alive',
'Content-Length': '288',
'Content-type': 'application/x-www-form-urlencoded',
'Host': 'homezz.ro',
'Origin': 'https://homezz.ro',
'Cookie': 'utc=2a43369f841'
'Referer': 'https://homezz.ro/garsonera-bucuresti-noi-decomandata-
1841433.html',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87
Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
}
data = {
'_token': 'bWHgtPKirbQSBxP0FJShDbmNReS5B2k2ThuN4OIJ',
'ad_id': '1841433',
'encrypted':'eyJpdiI6IklhTVlldnU2dFVqeXExVFRqS1dFXC93PT0iLCJ0'}
ajReq=requests.post('https://homezz.ro/ajax/phone-
number',timeout=10,headers=header,data=data)
print(ajReq)
print(ajReq.text)