如何使用python请求读取Ajax请求响应内容

我正在发出浏览器正在发出的确切请求,但没有获得浏览器显示的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)
MaiRongJian 回答:如何使用python请求读取Ajax请求响应内容

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3127714.html

大家都在问