如何編寫 Python 正則表示式來獲取網頁中的所有錨點標籤?


下列程式碼從給定字串中提取所有標籤

示例

import re
rex = re.compile(r'[\<\>]')
l = "this is text1 <a href='irawati.com' target='_blank'>hi</a> this is text2"
print rex.findall(l)

輸出

['<', '>', '<', '>']

更新於:2020 年 2 月 20 日

166 次瀏覽

開啟你的職業生涯

透過完成課程獲得認證

立即開始
廣告