关于爬虫的正则表达式一点记录

今天再爬虫的正则表达式里纠结了很久,记录下来,防止忘记再浪费时间

 content = requests.get(url)
        
 m=re.findall(r'<a href=\"([0-9a-zA-Z\_\/\.\%\?\=\-\&]+)\"',content.text,re.I)

一开始,我把content变成str(content)放在正则匹配式中,无法匹配,可能是因为str(content)是空的。

所以一定要用content.text来匹配

猜你喜欢

转载自www.cnblogs.com/crayszhangblog/p/11960754.html