beautifulsoup tag 的 function到底要在什麼時機使用呢?
指的是印出包含在title tag 那段html codeThe Dormouse's story
soup.title.name
會直接輸出title string
'title'
'title'
soup.title.string
多加string會輸出夾在title裡面的字串出來 'The Dormouse's story'
soup.title.parent.name
多加parent這個funtion的功能主要是要找出父輩的tag,意思就是有親子關係一般的上層tag(就是要找他老爸啦 !)輸出結果如下 'head'
soup.p
找到p tag 那段html代碼
把藏在 p tag 裡面的atrribute class 字串給抽出來 'title'
The Dormouse's story
soup.p['class']
把藏在 p tag 裡面的atrribute class 字串給抽出來 'title'
soup.a
將 a tag 的html抽出來
Elsie
將所有網頁內含有a tag 的html全部抽出來 Elsie, Lacie, Tillie
soup.find_all('a')
將所有網頁內含有a tag 的html全部抽出來 Elsie, Lacie, Tillie
soup.find(id="link3")
找到網頁內含有id 含有link3的html並將其抽出來
Tillie