- You want to retrieve the value of
THE PAGE YOU WERE LOOKING FOR DOESN'T EXIST.
from the URL of https://www.awwwards.com/error1/
.
If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
Issue and workaround:
I think that the page of your URL is Error 404 (Not Found)
. So in this case, the status code of 404
is returned. I thought that by this, the built-in functions like IMPORTXML
might not be able to retrieve the HTML data.
So as one workaround, how about using a custom function with UrlFetchApp? When UrlFetchApp is used, the HTML data can be retrieved even when the status code is 404
.
Sample script for custom function:
Please copy and paste the following script to the script editor of the Spreadsheet. And please put =SAMPLE("https://www.awwwards.com/error1")
to a cell on the Spreadsheet. By this, the script is run.
function SAMPLE(url) {
return UrlFetchApp
.fetch(url, {muteHttpExceptions: true})
.getContentText()
.match(/<h1>([\w\s\S]+)<\/h1>/)[1]
.toUpperCase();
}
Result:

Note:
- This custom function is for the URL of
https://www.awwwards.com/error1
. When you use this for other URL, the expected results might not be able to be retrieved. Please be careful this.
References:
If this was not the direction you want, I apologize.