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).

two ways.

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

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.

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

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.

To fully understand why a NullReferenceException is thrown, it is important to know the difference between value types and reference types.

So, if you’re dealing with value types, NullReferenceExceptions can not occur. Though you need to keep alert when dealing with reference types!

Only reference types, as the name is suggesting, can hold references or point literally to nothing (or ‘null’). Whereas value types always contain a value.

Reference types (these ones must be checked):

  • dynamic
  • object
  • string

Value types (you can simply ignore these ones):

  • Numeric types
  • Integral types
  • Floating-point types
  • decimal
  • bool
  • User defined structs