共计 842 个字符,预计需要花费 3 分钟才能阅读完成。
import re
htmlString = ‘<a href=”https://m.weibo.cn/p/index?containerid=100808edb33656f8aaf7c68add26ad8d0fdba4&extparam=%E6%97%A9%E9%A4%90&luicode=10000011&lfid=100103type%3D1%26q%3D%E8%85%8A%E8%82%A0″ data-hide=””><span class=\’url-icon\’><img style=\’width: 1rem;height: 1rem\’ src=\’http://n.sinaimg.cn/photo/5213b46e/20181127/timeline_card_small_super_default.png\’></span><span class=”surl-text”> 早餐 </span></a><br /> 腊肠蛋炒饭 + 奇异果????+ 奶茶☕️<br /> 这两日又风又雨的,这老天真是说变脸就变脸啊 <span class=”url-icon”><img alt=[笑 cry] src=”//h5.sinaimg.cn/m/emoticon/icon/default/d_xiaoku-7430606cb7.png” style=”width:1em; height:1em;” /></span> 来,喝杯奶茶压压惊 <span class=”url-icon”><img alt=[馋嘴] src=”//h5.sinaimg.cn/m/emoticon/icon/default/d_chanzui-ad3f4f182c.png” style=”width:1em; height:1em;” /></span> ‘
s2 = re.sub(r'<.*?>’,”,htmlString)
print(s2)
最终输出
早餐腊肠蛋炒饭 + 奇异果????+ 奶茶☕️这两日又风又雨的,这老天真是说变脸就变脸啊来,喝杯奶茶压压惊