Python 的 bs4 find_all 问题

2017-05-24 20:41:36 +08:00
 cwlmxwb

当我使用 soup.find_all(class="result content")时会报错,所以 class 内有多个字段时需要怎么做

1940 次点击
所在节点    问与答
7 条回复
broono
2017-05-24 20:59:14 +08:00
难道不是 class_吗
golmic
2017-05-24 21:15:55 +08:00
楼上正解
HGladIator
2017-05-24 21:21:55 +08:00
一楼正解
dd99iii
2017-05-24 21:23:16 +08:00
一楼
wangfeng3769
2017-05-24 21:43:31 +08:00
文档没好好看 class 后面加个下划
wangfeng3769
2017-05-24 21:44:14 +08:00
线就行了。
grimpil
2017-05-24 22:13:32 +08:00
因为“ class ”是 python 的保留关键字之一,所以使用 bs4 查找 class 时要用“ class_”代替,好象是这样吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/363559

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX