Google-sheets – ImportXML formula no longer working

google sheetsimportxml

Here is the formula:

=ImportXML("http://www.bloomberg.com/quote/7501:JP", "//div[@class='price-container down']//div[@class='price']")

As of several days ago, this formula stopped working. Why could this happen?

Best Answer

Something went wrong on Google's side, apparently. Other stock symbols import correctly. My uneducated guess is that there was a transmission error and a corrupted fetch result got stuck in Google's cache. I was able to break the cache by adding a redundant URL parameter: http://www.bloomberg.com/quote/7501:JP?param=1 fetched correctly.

By the way, the selector @class='price-container down' will only fetch the price if it's going down, because otherwise the classes will be price-contained up. To fetch the data in either case, use contains(@class,'price-container') instead:

=ImportXML("http://www.bloomberg.com/quote/7501:JP?param=1", "//div[contains(@class,'price-container')]//div[@class='price']")