當前位置:星座運勢大全官網 - 八字算命 - 漢字和正則表達式怎麽匹配?

漢字和正則表達式怎麽匹配?

壹般情況下,可以這樣匹配中文,如圖:&;amplt;img src = "/50/edcbd 2 faf 1a 916675 CEC 852 BD 886 e 599 _ HD . jpg " data-raw width = " 827 " data-raw height = " 600 " class = " origin _ image zh-light box-thumb " width = " 827 " data-o riginal = "/edcbd 2 faf 1a 91675 CEC 852 BDampgt;

先找到這個有湯或者有規律的節點,再和上面的字符組進行匹配。

假設只有壹個節點,用法如下:

從bs4 import beautiful soup URL = ' XXX ' html = req . get(URL)按要求導入重新導入請求。textbs = beautiful soup(html)span = bs . find _ all(' span ',' pro-title ')' ' ' span = re . find all(& lt;span\sclass="pro-title " >【^<;]+& lt;/span & gt;',html)s = span[0]m = re . find all('[\ u4e 00-\ u9fa 5]+',s)' ' ' s = str(span)m = re . find all('[\ u4e 00-\ u9fa 5]+',s)print(m)