好的,這就是我正在嘗試做的。我對 Python 還很陌生,我才剛剛掌握它。無論如何,使用這個小工具,我正在嘗試從頁面中提取數據。在這種情況下,我希望用戶輸入一個 URL 并讓它返回<meta content=" % Likes, % Comments - @% on Instagram: “post description []”" name="description" /> 但是,替換%為帖子的喜歡/評論等數量。這是我的完整代碼: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)但是每當我運行它時,我都會得到[]. 我究竟做錯了什么?
嘗試使用 BeautifulSoup 獲取元數據時出現意外結果
慕無忌1623718
2021-10-12 17:49:17