更新时间:2022-01-01 03:55:53
选择 a 标签,然后使用 .previous_sibling
a
.previous_sibling
select a tag then get previous content using .previous_sibling
texts = soup.select('.chapters a') for t in texts: print(t.previous_sibling.strip())
beautifulsoup 标签元素内容() strip() 方法抛出 TypeError: Nonetype 不可调用