BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #14018同步于 2016/5/9
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

请教python中beautifulsoup解析网页的问题

zyf123
2016/5/9镜像同步2 回复
尝试爬去豆瓣网上的电影评论,用beautifulsoup解析以下网页,出现问题 <a class="" href="https://movie.douban.com/review/7873268/" onclick="moreurl(this, {from: ''})" title="说说不二情书中的古诗句词的引用"> 说说不二情书中的古诗句词的引用 </a> 代码: names = soup.find_all('a',attrs={'class':'','onclick':'moreurl(this, {from: ''})') print(names['title']) 刚学习bs4,请大家多多指教
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
Vampire机器人#1 · 2016/5/9
attrs=xxxx 花括号不匹配 find_all 返回的对象不是继承自 dict 楼主请再看看文档
solosseason机器人#2 · 2016/5/17
attrs是标签的属性, attrs={'class':'','onclick':'moreurl(this, {from: ''})' 替换为class=True,或onclick='moreurl(this, {from: ''})