mercredi 30 juin 2021

How to make beautiful soup ignore finding a value if it doesn't exist

When I try to scrape a website. I got this error

" f.write (ary[0]["value"]+ ",") File "C:\python39\lib\site-packages\bs4\element.py", line 1406, in __getitem__ return self.attrs[key] KeyError: 'value'" Because sometimes that page doesn't have the Value. So How can I make it ignore it and keep executing the rest of the code?




Aucun commentaire:

Enregistrer un commentaire