soup = BeautifulSoup(html_content, 'html.parser')
### 查找指定class的table
labels = soup.find_all("table", class_="cls_name")
### 查找指定id的table
label = soup.find("table", id_="cls_id")
### 正则匹配指定的url
links = table.find_all("a", href=re.compile(r"/[0-9]+.html"))
### 获取标签的纯文本
text = label.text
text = label.get_text()
最后
以上就是甜美鸭子最近收集整理的关于BeautifulSoup 用法记录的全部内容,更多相关BeautifulSoup内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复