I'm using the following function go grab some stock data from a website
=index(split(index(IMPORTHTML("https://finance.yahoo.com/quote/"&A27,"Table", "2"),6,2)," "),1)
It works perfectly for every stock ticker except one, where it gives "Error: resource at url not found"
I double checked and the ticker name is correct in the A column, the link works if I write it in like that manually. The yahoo page with TGH ticker does contain the info I need and exactly the same way as any other ticker...I'm just lost on why it doesn't work in this single case.
See pic below:
GoogleSheets
Related
Am trying to pull out date fr4om Money control form this function (https://www.moneycontrol.com/indices/fno/view-option-chain/BANKNIFTY/2022-07-28) what could be the formula for This & how we get multiple stock data like nifty, banknifty ,& stocks in variable expiry i used this this ( =IMPORTHTML("https://www.moneycontrol.com/indices/fno/view-option-chain/"&AD3&"/"&W253"","table",2)) but error occurred
I was able to successfully import the table from the mentioned URL using the following formula:
=IMPORTHTML("https://www.moneycontrol.com/indices/fno/view-option-chain/BANKNIFTY/2022-08-04", "table", 2, "en_US")
However you've mentioned that an error ocurred, but you haven't shared the error...
Since you are concatenating parameters to the URL being fetched, I'd recommend investigating the end result of the concatenation and try accessing that newly concatenated URL on a browser to see if it works.
Additionally, I’d recommend adhering to the How to Ask guidelines in order for your questions to be properly answered by the community as well as to provide a minimal reproducible example when posting a question.
I'm trying to pull the "Trophy points" value from https://trackmania.io/#/player/acf21a42-f517-42cc-a1b2-e8e7693da4ca using the following:
=IMPORTXML("https://trackmania.io/#/player/acf21a42-f517-42cc-a1b2-e8e7693da4ca","//*[#id='content']/div/section[2]/div/div[2]/div[2]/div[2]/table/tr[1]/td")
When I try this, the cell returns "#N/A" and when I hover "Imported content is empty". The only reason I can think of is that the data on the website hasn't loaded by the time Sheets attempts to pull the data, so it returns with no value.
your assumption of the not-loaded site is incorrect. the issue is the website itself that uses JavaScript. IMPORT formulae of google sheets does not support scrapping of JS elements. any such attempt will lead to #N/A error and imported content will be empty. you can always check this by doing:
I want to get the price of an item which is market in steam. I tried to use this formula but it is not working it tells me that the value is too big. and I did not know what to do. I want to get the price of an item which is on market on steam.
Blockquote =VALUE(REGEXEXTRACT(REGEXEXTRACT(CONCATENATE(IMPORTXML("https://steamcommunity.com/market/listings/730/Clutch%20Case", "//script[2]")),".*]]"), "[0-9]+.[0-9]+"))
The main problem here is that the prices in the Steam page are generated by Javascript and IMPORTXML cannot retrieve dynamically generated data. It seems that you're trying to get around this by importing a <script> section, but this will not execute the script, you're just grabbing a bunch of code.
According to this answer, Steam has some endpoints that you can use to get market data. These return a simple JSON string with the item information. The endpoint looks like this:
http://steamcommunity.com/market/priceoverview/?currency=1&appid=[ID]&market_hash_name=[Item name]
The appid is the game's ID, and the market_hash_name is the URL-encoded name of the item. Conveniently you can already find these in the URL that you are already using, https://steamcommunity.com/market/listings/730/Clutch%20Case. The game ID is 730 and the name is Clutch%20Case. So you can plug these in to the endpoint to get this URL:
http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=Clutch%20Case
The endpoint's JSON looks like this:
{
"success":true,
"lowest_price":"$0.30",
"volume":"94,440",
"median_price":"$0.31"
}
Since you only care about the median price, we can use a formula with REGEXEXTRACT to extract only that part:
Here's a sample pasting the URL in A1.
=REGEXEXTRACT(JOIN("", IMPORTDATA(A1)), "median_price:""(\$[0-9]+.[0-9]+)")
Edit: As mentioned in the answer I linked, you can test the currency parameter in the URL with different numbers to get other currencies. In your case you can try currency=2for pounds (£). You'll also have to edit the REGEXEXTRACT to account for this change:
URL: http://steamcommunity.com/market/priceoverview/?currency=2&appid=730&market_hash_name=Clutch%20Case
Formula: =REGEXEXTRACT(JOIN("", IMPORTDATA(A1)), "median_price:""(£[0-9]+.[0-9]+)")
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.
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
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
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.
This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
Using this webpage as an example http://forums.macrumors.com/showthread.php?t=1688317
On a google spreadsheet, the following DO NOT work with importxml():
//a[contains(#href,"showpost")]/#href
//a[contains(#href,"showcount")]/#href
//*[#id="postcount18545482"]
The last one (//*[#id="postcount18545482"]) was copied directly from Chrome's element viewer.
The following DO work but exclude any results with the word "showcount", "postcount", or "showpost":
//div[contains(#id,"post_message")]/#id
//a[contains(#href,"show")]/#href
//a[contains(#href,"post")]/#href
Is there something special about the word "count" when working with importxml() or XPATH? How can I get the missing entries?
ImportXML function in Google Docs spreadsheet can not process data that is created in a two-step process. For example, when an authentication token must be retrieved first before making the url request, or when the URL tells the server to dynamically create an xml output after which the user is redirected to the output, even when the URL stays the same. You might want to look into Google Apps Scripts (http://code.google.com/googleapps/appsscript/index.html) to handle this case.
Taken from here
In your particular case the anchor parameters get set in the vbulletin_post_loader.js script called after the page container is loaded.
...
pc_obj=fetch_object("postcount"+this.postid);
openWindow("showpost.php?"+(SESSIONURL?"s="+SESSIONURL:"")
+(pc_obj!=null?"&postcount="+PHP.urlencode(pc_obj.name):"")+"&p="+A)
...
In other words, when importXML() scans the page, the nodes containing 'showpost' or 'postcount' in href are not yet on the page:
Looks like importXML() works with static pages only and not able to handle dynamically loaded content.
Try to find another way of obtaining the number of post in a thread.