ThingHTTP Example not working

Hey,
I'm really new on this and I really don't know how y'all doing it, but I can't even get the ThingHTTP Example to work.
Whatever I'm trying, I always get the message "Error parsing document, try a different parse string."
I'm creating a new ThingHTTP and it brings me to the page with all the parameters.
From the example, step 1, I copy the "https" bitcoin-link into the URL-field. Method is left at "GET"
Finally, from the example, step 3, I copied the full X-Path into the "Parse String" field and clicked "Save ThingHTTP", which brougth me back to the first page.
I copied the "https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXXXXXXXXXXXXXXX" into a new browserpage and I'm back at the error message.
So I thougth something was changed on the "bitcoin" site.
Went to "https://www.coinbase.com/price/bitcoin", (I'm using Chrome) and selected the element I wanted, and copied the full X-Path from there.
Again, pasted into the "Parse Field" and saved the ThingHTTP again.
I copied the "https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXXXXXXXXXXXXXXX" into a new browserpage and yet again........back at the error message.

 Accepted Answer

Vinod
Vinod on 26 Mar 2020
Edited: Vinod on 26 Mar 2020
It appears Coinbase changed their CSS or page layout, yet again. Try this instead:
In the URL field, enter: https://cointelegraph.com/
In the parse string field, enter: //*[@id="header"]/header/div/div[1]/div/div[2]/ul/li[1]/a/span[2]
Now make the ThingHTTP request from your browser. Does it work?

More Answers (1)

Ryszard Olszewski
Ryszard Olszewski on 17 Jun 2020
Hi,
I have the same issue with website Investing.com
When I try get price quote f.ex. from website https://www.investing.com/indices/us-spx-500 I get message:
"Error parsing document, try a different parse string."
Probably something they changed, because everything was working fine for many weeks until now.
When I inspect Xpath I can see that this is the same as previous one, so I don't know what can I do.
Could you help me find any solution?
Many thanks!

4 Comments

Vinod
Vinod on 18 Jun 2020
Edited: Vinod on 18 Jun 2020
It appears like investing.com is blocking the thingspeak agent from making requests to the site. If you creaed a new thinghttp with no parse string and the URL set to https://www.investing.com, you will see that. Compare that behavior to using a different URL.
So, in this situation, you could use MATLAB analysis, with the following code:
urlfilter('https://www.investing.com/indices/us-spx-500','last_last')
That will give you the number. Then, you can schedule this MATLAB analysis to write this value into a channel's field every so often, and you then read out the value as needed usign the ThingSpeak API.
Thank's for the great idea!
Is it possible to use this MATLAB analysis every 1 minute? (in Time Control I can see recurring for every 5 minutes in the shortest option).
The another thing, I think more dificult is that I would like to schedule hours and days when this analysis will be working - there is no need to run this at night or at Saturdays or Sundays..
Vinod
Vinod on 23 Sep 2020
Edited: Vinod on 23 Sep 2020
You can always have your MATLAB code have the "weekends" logic and write the price to your channel only on weekdays (and in your timezone, if that matters). Let TimeControl execute the MATLAB code every 5 minutes. At this time, every 5 minutes is the most frequently a TimeControl can schedule a MATLAB code execution.
I've noticed that values stored in Channels don't have two decimal points.
For example when value from MATLAB code is "123.00", then in the Channel only "123" is stored. In this way I got values with different, random lenght which is not good for my project. I use "format bank" in MATLAB analyse code.
I've tried some functions which convert string to float or double, but "0.00" is returned. Is there any chance to save to- or read from channel values always with two decimal digits - "1.23"?
Moreover it would be really nice if positive values would be with "+" at the beginning.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Categories

Products

Tags

Asked:

on 26 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!