NullReferenceException

scraping
studio
exception

#1

Hello good people. I’m getting an error with this setup. I am scraping an amazon page to get the prices/see if its sold thru amazon/other sellers/and their ratings. I believe i am getting this error because sometimes there is no data to grab from the site, leaving a blank “cell” where there is no information. How do i go about fixing this problem? I’ve spent about 4 hours searching for an answer but to no avail.

Object reference not set to an instance of an object. this error usually occurs when using a variable with no set value (not initialized).


#2

Hi,
two ways.

1.Check DataTable.Rows.Count.ToString=“0” in if condition and perform according (maybe retry or next operation)
OR
2. Simply enclose in Try/Catches activity.


#3

What should I put in the “catches” section, what are the ways of fixing the error? Can i fill in the data with a zero or better yet, if there is no data scraped, just leave it blank in the spread sheet? Thank you very much ddpadil for replying.


#5

Please check the variables are defined already or not. If not, declare the variable and try again.


#6

You can also implement an additional check using Element exists activity. It outputs a Boolean when something specific is present on the page, like your table. You can then use an if statement to only do the scraping if the table exists. Hope it helps.