-4

I am new to Python and I am trying to get information on stock market prices from a website. If I use the following code:

data = [[td.text.strip() for td in tr.findChildren('td')] 
    for tr in table.findChildren('tr')]

I get the following error:

AttributeError: 'NoneType' object has no attribute 'findChildren'

Not sure how to go about fixing this. Any help would be appreciated.

  • Please go through the [intro tour](https://stackoverflow.com/tour), the [help center](https://stackoverflow.com/help) and [how to ask a good question](https://stackoverflow.com/help/how-to-ask) to see how this site works and to help you improve your current and future questions, which can help you get better answers. We expect you to at least look up the error message and try to trace the offending values within your program. – Prune Feb 24 '21 at 07:27

1 Answers1

1

The error message means that tr or table is None, and you tried to call findChildren() on that object. Your example code is not self-contained, so I cannot tell how you set those variables.

Allan Wind
  • 23,068
  • 5
  • 28
  • 38