cwlmxwb
V2EX  ›  问与答

Python 的 bs4 find_all 问题

  •  
  •   cwlmxwb · May 24, 2017 · 2701 views
    This topic created in 3286 days ago, the information mentioned may be changed or developed.

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

    7 replies    2017-05-24 22:13:32 +08:00
    broono
        1
    broono  
       May 24, 2017 via Android
    难道不是 class_吗
    golmic
        2
    golmic  
       May 24, 2017 via Android
    楼上正解
    HGladIator
        3
    HGladIator  
       May 24, 2017
    一楼正解
    dd99iii
        4
    dd99iii  
       May 24, 2017
    一楼
    wangfeng3769
        5
    wangfeng3769  
       May 24, 2017 via Android
    文档没好好看 class 后面加个下划
    wangfeng3769
        6
    wangfeng3769  
       May 24, 2017 via Android
    线就行了。
    grimpil
        7
    grimpil  
       May 24, 2017
    因为“ class ”是 python 的保留关键字之一,所以使用 bs4 查找 class 时要用“ class_”代替,好象是这样吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 65ms · UTC 20:04 · PVG 04:04 · LAX 13:04 · JFK 16:04
    ♥ Do have faith in what you're doing.