Using BeautifulSoup to extract specific dl and dd list elements

前端 未结 2 1309
别跟我提以往
别跟我提以往 2021-01-20 01:56

My first time posting. I am using BeautifulSoup 4 and python 2.7 (pycharm). I have a webpage containing elements and I need to extract specific elements where the tags

2条回答
  •  梦谈多话
    2021-01-20 02:50

    I guess it works if you just omit the .parent in your code. At least this worked for my problem which is very similar to yours.

    Here's my html, where order of the

    is not guaranteed:

    Time
    10:05:02
    Temp
    20.5°C

    I'm accessing the values successfully with the following code:

     time = at_tl.find("dt",text="Time").findNext("dd").string
     temp = at_tl.find("dt",text="Temp").findNext("dd").string
    

提交回复
热议问题