[問題] 找出部份符合特定字串的html tag

看板Python作者時間4年前 (2020/10/31 20:10), 編輯推噓2(202)
留言4則, 3人參與, 4年前最新討論串1/1
<div id="a">123 456</div> <div id="b">456</div> <div id="c">123 456 789</div> soup.findAll('div', text = re.compile('456')) 只會傳回 div B. soup.findAll('div', text = re.compile('45')) 也只會傳回 div B. a與c明明也有部份符合,是語法錯誤嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.91.127 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1604146233.A.575.html

11/01 00:42, 4年前 , 1F
我用colab和vscode都正常耶
11/01 00:42, 1F

11/01 10:02, 4年前 , 2F
前後加.*試試?
11/01 10:02, 2F

11/01 17:01, 4年前 , 3F
vscode測試正常+1 你的soup parse的內容只有那3個tag嗎
11/01 17:01, 3F

11/01 17:01, 4年前 , 4F
11/01 17:01, 4F
文章代碼(AID): #1VdLGvLr (Python)
文章代碼(AID): #1VdLGvLr (Python)