0

I'm trying to fetch part of a single table from an HTML page into my Google spreadsheet. Been having lots of problems. importhtml() fails quite regularly (but not always) and simply displays "loading..." forever. So I decided to try UrlFetchApp() instead. Having problem with it as well.

Here is the URL I'm trying to fetch:

http://finance.yahoo.com/quote/COH160916P00041000?p=COH160916P00041000

My importhtml() version is simply:

=index(IMPORTHTML("http://finance.yahoo.com/quote/COH160916P00041000?p=COH160916P00041000","table",1),3,2)

As I mentioned this does work... mostly. But it breaks too often to be dependable. How can I accomplish the same thing using UrlFetchApp()?

I just discovered something very strange related to this. This formula works fine:

=IMPORTHTML("http://finance.yahoo.com/quote/coh160916P00040000","table",1)

This displays "Loading..." indefinitely:

=IMPORTHTML("http://finance.yahoo.com/quote/COH160916P00040000","table",1)

The only difference is the capitalization of "COH" in the second one. That is the correct URL on Yahoo's site:

http://finance.yahoo.com/quote/COH160916P00040000

So what gives?

  • My first impression was that this would be related to the solution presented in another question of mine: http://webapps.stackexchange.com/questions/97409/google-sheets-do-named-ranges-not-work-under-certain-conditions however, my example in this question does work most of the time, it just fails sometimes and I don't know why. – Jonathan van Clute Aug 10 '16 at 20:58
  • The question is too broad. Please describe your research efforts and/or include the code that you tried. – Rubén Aug 11 '16 at 11:41
  • I don't understand, I have included the code I have used and explained my discovery regarding capitalization. I have been scouring the internet looking for information on this but have not found the answers I'm seeking. I'm looking for a reliable way to fetch data into a spreadsheet from a remote http URL. What is so broad about that? – Jonathan van Clute Aug 11 '16 at 15:47
  • I only see the name of one method not something that could be considered code in the context of Google Sheets. IMHO you should include something that looks like the examples provided in the official documentation for urlFetchApp, even better if you include a minimal, complete and verifiable example. – Rubén Aug 11 '16 at 16:42
  • I don't know how to use it, that's why I'm asking about using it. I've read the documentation, it was no help. I've read and tried countless examples, none of them worked either. I know enough to know that urlfetchapp should be able to do what I need, and may be more reliable than a function placed on the sheet, and that's why I'm exploring it. But I have no working code at all so that's why I am here to get an example that would work with the URL I'm trying to fetch. – Jonathan van Clute Aug 11 '16 at 16:46
0

Turns out importxml() is the way to go without a doubt. Works great!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.