穿靴子的猫2 短评数量 - Python爬虫代码示例 日期: 2024-10-20 标签: 常规 <a class='comment_btn j a_show_login' href='https://www.douban.com/register?reason=review' rel='nofollow'> <span>我要写短评</span> </a> <h2> <i class=''>穿靴子的猫2的短评</i> · · · · · · <span class='pl'> ( <a>全部 32103 条</a> ) </span> </h2> </div> 我现在写爬虫代码,想定位上面div(id='comments-section')下的span(class='pl')内容:可以使用以下代码定位: pl_span = soup.find('div', {'id': 'comments-section'}).find('span', {'class': 'pl'}) 其中,soup为BeautifulSoup对象,表示解析后的HTML页面。解析HTML页面可以使用BeautifulSoup(html, 'html.parser')方法。 原文地址: https://www.cveoy.top/t/topic/oBd8 著作权归作者所有。请勿转载和采集! 免费AI点我,无需注册和登录 上一篇: 如何用 Python BeautifulSoup 获取豆瓣短评数量 下一篇: 穿靴子的猫2 短评数量获取 - Python BeautifulSoup 代码示例
我现在写爬虫代码,想定位上面div(id='comments-section')下的span(class='pl')内容:可以使用以下代码定位:
其中,
soup为BeautifulSoup对象,表示解析后的HTML页面。解析HTML页面可以使用BeautifulSoup(html, 'html.parser')方法。