Search code examples
google-sheetsgoogle-sheets-formulaxpathquery

GoogleSheet: IMPORTXML error, resource at url not found?


What you will see from images below is that A1 is filled with random number which generated from the script. The number will change randomly every-time cursor is moved, it's used in method for "forcing update the XML data" in Google Sheets.

Picture 1

as we can see from the 1st picture, the IMPORTXML worked like charm, using =IMPORTXML("Link" &A1(which is the random number, that is needed to update the data), "//target content") recipe

Well, it worked out for the 1st link, but not really for the second one, in the 1st image, B2 is using the last link, and it shows 1736.5 as the value, that is showing fine without using &A1 code

Picture 2

After adding &A1 to the formula, it gives error #N/A and Resource at url not found as the error detail.

I already tried to use another cell with calculated numbers(more than A1 or less than), still gives me that error.


Solution

  • Solution

    If you look closely to the second URL you will notice it finishes with an = sign. In URLs this symbol is used to express key values pairs. Using your refresh trick, in this case, you are specifying to the server to look for a resource that actually doesn't exist. Hence the IMPORTXML error. Just put the generated URL in the browser to see the result.

    Try to put another random parameter in the URL that will cause to refresh the page without causing a 404 HTTP error.

    For example:

    https://www.cnbc.com/quotes/?symbol=XAU=&x=0
    

    Won't cause any error and will give the desired result.