好的,這就是我正在嘗試做的。我對(duì) Python 還很陌生,我才剛剛掌握它。無(wú)論如何,使用這個(gè)小工具,我正在嘗試從頁(yè)面中提取數(shù)據(jù)。在這種情況下,我希望用戶輸入一個(gè) URL 并讓它返回<meta content=" % Likes, % Comments - @% on Instagram: “post description []”" name="description" /> 但是,替換%為帖子的喜歡/評(píng)論等數(shù)量。這是我的完整代碼:from urllib.request import urlopenfrom bs4 import BeautifulSoupimport requestsimport reurl = "https://www.instagram.com/p/BsOGulcndj-/"page2 = requests.get(url)soup2 = BeautifulSoup(page2.content, 'html.parser')result = soup2.findAll('content', attrs={'content': 'description'})print (result)但是每當(dāng)我運(yùn)行它時(shí),我都會(huì)得到[]. 我究竟做錯(cuò)了什么?
嘗試使用 BeautifulSoup 獲取元數(shù)據(jù)時(shí)出現(xiàn)意外結(jié)果
慕無(wú)忌1623718
2021-10-12 17:49:17