發(fā)現(xiàn)一個(gè)頁(yè)面用常規(guī)的配置header里面的host,U-A后,依舊不能獲取頁(yè)面數(shù)據(jù).
通過(guò)調(diào)試工具檢查過(guò)發(fā)送的get命令,并沒(méi)有差異。
實(shí)在找不到原因,難道是我缺少那部分的知識(shí)。
求助各位大佬
地址如下:
目標(biāo)采集頁(yè)面
import requests
url_Header = {'Host': 'www.realestate.com.au',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0'}
url_tar = "https://www.realestate.com.au/property/unit-5-29-stephenson-st-pialba-qld-4655"
r = requests.get(url_tar,headers=url_Header)
if r.status_code == 200:
print(r.text)
else:
print(r.status_code)
我這邊采集到的錯(cuò)誤結(jié)果如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="about:blank">
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://resources.kasadapolyform.io/kpfp.js"></script>
<script src="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint/script/kpf.js?url=/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint&token=iqyvb0Jj-vnBK-gLSc-eYbn-qSQoY37FIfzn"></script>
</head>
<body>
</body>
</html>
請(qǐng)教是哪種情況我沒(méi)考慮到嗎?
無(wú)需考慮其他xhr內(nèi)容,僅需要Get Hmtl高亮這條命令的內(nèi)容。
只是不知道為什么不能request到同樣的內(nèi)容。
商業(yè)網(wǎng)站怎么可能不防爬,這個(gè)是動(dòng)態(tài)加載的,信息都分塊動(dòng)態(tài)加載啦,你F12捉一下xhr的包看一下,我就看到了幾個(gè)包對(duì)應(yīng)著school啊,Property timeline for 5/29 Stephenson Street啊,Similar homes in Pialba的信息,都是json數(shù)據(jù)看著辣眼,丟到排版器排一下看看吧
如果你只想要那個(gè)包的話就帶上cookie去請(qǐng)求,幾得把cookie轉(zhuǎn)成字典再丟過(guò)去,實(shí)測(cè)成功
import requests
cookie = '*********************'
url = 'https://www.realestate.com.au/property/unit-5-29-stephenson-st-pialba-qld-4655'
headers = {'referer': 'https://www.realestate.com.au/property/unit-5-29-stephenson-st-pialba-qld-4655',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36'
}
def trans_cookie(cookie):
items =cookie.split(';')
item_dict = {}
for item in items:
key = item.split('=')[0].replace(' ', '')
value = item.split('=')[1]
item_dict[key] = value
print(item_dict)
return item_dict
cookies = trans_cookie(cookie)
r = requests.get(url,cookies=cookies,headers=headers)
with open('gg.txt','w',encoding='utf-8') as f:
f.write(r.text)
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
北大青鳥(niǎo)中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過(guò)二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。