How do I extract table data in pairs using BeautifulSoup?

后端 未结 2 1835
無奈伤痛
無奈伤痛 2021-01-04 22:47

My data sample :

Google07/11/2001
2条回答
  •  孤城傲影
    2021-01-04 23:15

    Here is small variation of Sean answer if you need exactly what you wrote in question,

    table = soup.find("table", id = "history")
    
    rows = table.findAll('tr')
    
    data = ['|'.join([td.findNext(text=True) for td in tr.findAll("td")]) for tr in rows]
    print data
    

提交回复
热议问题