Try Catch Web Scraping

I am doing web scraping and I am pulling a description from different pages. It sometimes only shows a preview of the description. There is a button on some pages called “show more” for longer descriptions that you click and it shows the rest of the description. I tried making a Try Catch to click “show more” so that is it does not exist it will just continue to scraping the description.

Why am I getting this error that it cannot find the element. Shouldnt the script just continue if it does not exist?

image

You should use generic “Exception” inside the catch block… as this doesn’t look like the “argument exception” you have specified… Exception will capture all types of exceptions…

Just change ArgumentException to Exception.

Hi @bfmugri , For “Show More” you can do with element exist. If it exists click and grab description else garb what is visible.

And in Exception get System.Exception so it will show all kind of exceptions.

image