V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
cwlmxwb
V2EX  ›  问与答

Python 的 bs4 find_all 问题

  •  
  •   cwlmxwb · 2017-05-24 20:41:36 +08:00 · 1934 次点击
    这是一个创建于 2521 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    7 条回复    2017-05-24 22:13:32 +08:00
    broono
        1
    broono  
       2017-05-24 20:59:14 +08:00 via Android
    难道不是 class_吗
    golmic
        2
    golmic  
       2017-05-24 21:15:55 +08:00 via Android
    楼上正解
    HGladIator
        3
    HGladIator  
       2017-05-24 21:21:55 +08:00
    一楼正解
    dd99iii
        4
    dd99iii  
       2017-05-24 21:23:16 +08:00
    一楼
    wangfeng3769
        5
    wangfeng3769  
       2017-05-24 21:43:31 +08:00 via Android
    文档没好好看 class 后面加个下划
    wangfeng3769
        6
    wangfeng3769  
       2017-05-24 21:44:14 +08:00 via Android
    线就行了。
    grimpil
        7
    grimpil  
       2017-05-24 22:13:32 +08:00
    因为“ class ”是 python 的保留关键字之一,所以使用 bs4 查找 class 时要用“ class_”代替,好象是这样吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5421 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 03:35 · PVG 11:35 · LAX 20:35 · JFK 23:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.