Get information from the Internet

Hi!
I am working on a project with svyazannoy bluetooth and arduino. The algorithm looks like this:
If you press the button, Arduino sends the symbol "49" to the application.
If the application receives the symbol "49", then the application goes to the site and learns the time and uses html to copy the time and paste it into Label2.

The application receives and sends. The problem is, the app accessing the site does not receive the information. Please help me?



Everything seems to be a mistake in this block
A few months ago, everything worked. It seems that the structure of the site where I take information has changed.
Can you please help?
blocks (4)

This is not a mistake. I wrote you in another thread that the owner of the page you are trying to scrape has introduced protection and you will not get information from this page anymore. Look for another site from which you can get time, preferably not by scraping, but through the API

e.g. here:

1 Like

Can I use the same API in all applications?

Registered on the website World Time API - API Ninjas

I got the necessary API key, then what do I need to do?

I did it like this:

Please tell me where to insert the API?
Is returning:
{"error": "Missing API Key."}

https://api.api-ninjas.com/v1/worldtime?city=london&api_key=your_api_key
Instead of "your_api_key" I inserted my API.
But it doesn't work

Every API page has FAQ or HOW TO information, you need to look on that site for how to build the query. You probably need to put the api key in the query.

When I get home, I'll try to help.

1 Like

Which response content do you get in the Web.GotText Event?

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

Try this api, without registration and api_key....

http://worldtimeapi.org/api/timezone/America/New_York

We get the answer in JSON:

{
"abbreviation":"EDT",
"client_ip":"2001:1c05:124:2600:dcde:a379:20b7:b51",
"datetime":"2023-03-27T09:42:23.752719-04:00",
"day_of_week":1,
"day_of_year":86,
"dst":true,
"dst_from":"2023-03-12T07:00:00+00:00",
"dst_offset":3600,
"dst_until":"2023-11-05T06:00:00+00:00",
"raw_offset":-18000,
"timezone":"America/New_York",
"unixtime":1679924543,
"utc_datetime":"2023-03-27T13:42:23.752719+00:00",
"utc_offset":"-04:00",
"week_number":13
}

And with these blocks you can read the hours:


1 Like

Thanks! I did exactly the same, but I have this error



what do you get if you click this link http://worldtimeapi.org/api/timezone/America/New_York
your response in the browser should look like this

Unbenannt2

Taifun

1 Like

I get it if I click the link:
{"abbreviation":"EDT","client_ip":"194.0.188.113","datetime":"2023-03-27T16:11:32.912591-04:00","day_of_week":1,"day_of_year":86,"dst":true,"dst_from":"2023-03-12T07:00:00+00:00","dst_offset":3600,"dst_until":"2023-11-05T06:00:00+00:00","raw_offset":-18000,"timezone":"America/New_York","unixtime":1679947892,"utc_datetime":"2023-03-27T20:11:32.912591+00:00","utc_offset":"-04:00","week_number":13}


Those very same blocks worked fine here in New York when dragged from the board into AI2.

The web site might be fussy.

1 Like

Hello, it turns out I made a mistake with one block. Fixed it. I did the following:
When Label1 receives the time, the application via Bluetooth should only send the hour and minutes via one digit each. Every 50 ms seconds.
If the time is 10:30, Bluetooth sends:

1 (after 50 ms)
0 (after 50ms)
: (after 50ms)
3(after 50ms)
0(after 50ms)

I put together such a block, but there is some kind of error in it. Please tell me?




blocks (11)

What effect do you get? Try moving the block that disables the clock.

1 Like

I did exactly the same thing, but Bluetooth does not send the characters correctly and is very laggy

What do you mean it's not sending characters correctly? What do you get in arduino? Perhaps the bluetooth component takes more than 50ms to send data.

1 Like

Sometimes it sends characters, now it has stopped sending at all
Now even the time is not displayed on the label
50 ms for bluetooth is enough, I think, because it worked like that on another project

Arduino receives this message


The application receives this message