requests後用 soup.find 找不到指定標籤的原因分析

在實踐中,用 Microsoft Edge 瀏覽器打開了 www.santostan.com 進行BeautifulSoup.find()方法的學習實踐,開發工具看到的源代碼如下:

我想找到選中的標籤,所以用瞭如下的代碼:

import requests
from bs4 import BeautifulSoup

headers = {'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gec'
                          + 'ko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362',
           "host" : "www.santostang.com",
           }
link = "http://www.santostang.com/"
r = requests.get(link,headers=headers,timeout=15)
soup = BeautifulSoup(r.text,"html.parser")
print(soup.prettify())
sp = soup.find("div",id="titleBar")
print("\nsp = ",sp)

但得到的結果是:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章