Dec-22-2022, 07:12 PM
(This post was last modified: Dec-22-2022, 07:12 PM by deanhystad.)
I don't understand why you would use indexing with find_all(). I would expect code to iterate over the find_all() results, and an index error would not be possible.
Can you post an example of code where indexing is required? In your posted example don't see why you didn't use find() instead of find_all().
But if you did need to use find_all() you could do it like this.
Can you post an example of code where indexing is required? In your posted example don't see why you didn't use find() instead of find_all().
But if you did need to use find_all() you could do it like this.
if title_selector := content.findAll('h1', attrs={"itemprop": "title"}) title = title_selector[0].text