AttributeError when extracting data from a URL in Python

前端 未结 2 1434
夕颜
夕颜 2021-01-25 08:12

I am using the code below to try an extract the data at the table in this URL. However, I get the following error message:

Error: `AttributeError: \'NoneType\' o         


        
2条回答
  •  迷失自我
    2021-01-25 09:01

    There are a lot of issues in your code.

    1. There is no table with class 'tablestats'.
    2. There are no 'th' fields with class 'header'.
    3. Following line-

      table_items = [(a.text, b.text) for ele in data for a, b in [ele.find_all("td")]]

    doesnt return just 2 values, so cant assign to a, b

提交回复
热议问题