Python beautifulsoup - getting input value

后端 未结 2 1160
礼貌的吻别
礼貌的吻别 2021-01-01 15:48

I\'ve got many table rows like this:


    100
    200
    

        
相关标签:
2条回答
  • 2021-01-01 16:16
    soup = BeautifulSoup(html)
    try:
        value = soup.find('input', {'id': 'xyz'}).get('value')
    except:
        pass
    
    0 讨论(0)
  • 2021-01-01 16:32

    You want to find the <input> element inside the cell, so you should use find/find_all on the cell like this:

    cells[2].find('input')['value']
    
    0 讨论(0)
提交回复
热议问题