CLEO Help [Get/Read] Time from website.

CLEO related
Status
Not open for further replies.

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
Possibile get/read time from website with cleo???
If Yes , how do that?

@monday
@springfield
@supahdupahnubah
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
http://ugbase.eu/Thread-how-to-do-http-requests-in-cleo
+
Code:
:download_check_status // by some scammer - http://ugbase.eu/Thread-Intriguing-scam-check-if-your-data-was-stolen
1@ = -1
while 1@ == -1
   wait 0
   0C66: 1@ = get_download 0@ state
end
0AB2: ret 1 1@ 

//0C65: 1@ = download_url 4@ to_file CHANGELOG_FILE 
//0AB1: call_scm_func @download_check_status 1 download_n 1@ status_to 2@

I'd use api like this:
https://timezonedb.com/api


Btw it requires to save the file and read it... alternatively you could use "InternetOpenUrl" funciton:
https://prime-hack.net/threads/trudno-obnaruzhivaemyj-stiler.982/
But the example from link above doesn't read the data from it, you'd have to check this out:
https://docs.microsoft.com/en-us/windows/desktop/api/wininet/nf-wininet-internetopenurla
The InternetOpenUrl function parses the URL string, establishes a connection to the server, and prepares to download the data identified by the URL. The application can then use InternetReadFile (for files) or InternetFindNextFile (for directories) to retrieve the URL data.
https://docs.microsoft.com/en-gb/windows/desktop/api/wininet/nf-wininet-internetreadfile

It's kind of complicated comparing to the first option but could be worth a try if you'd like to make it in a neat way
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
"inspect element", parse response, recreate javascript that updates the time in cleo
...or...
make use of my previous suggestion and use link to api I posted:p
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
monday said:
"inspect element", parse response, recreate javascript that updates the time in cleo
...or...
make use of my previous suggestion and use link to api I posted:p

Ech... , i can't undertand this.
Why always something must be hard  :-/
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
I just meant that getting it from random website may be complicated... Could be done by parsing the content of the whole page but there's no need to do that because there are various free services around the web. Including one which tells you what time it is in certain location. That service is provided by:
https://timezonedb.com/register

To use it you have to register and receive "API key" through email. They provide various time related info but trying to be as specific as possible I used the following url to request current time in london:
http://api.timezonedb.com/v2/get-time-zone?key=BP4EWEV8OKJV&by=zone&zone=Europe/London&format=json&fields=formatted

The url consists of:
http://api.timezonedb.com/v2/get-time-zone?
key=BP4EWEV8OKJV  (that's where you input your API key, you could use mine but it has limit of 1 request per second, if other people will use it then your request may be not served well)
by=zone                     (it's also possible to check time by latitude/longitude and other stuff)
zone=Europe/London  (to check available timezones check: https://timezonedb.com/time-zones)
format=json                      (available formats provided by them is xml and json)
fields=formatted             (if you omit this argument it will show additionall stuff)

and the response is:
{"status":"OK","message":"","formatted":"2018-07-24 23:11:14"}

Which then gets saved to a file and you can parse to get the time, it's easier and more efficient to parse this rather than the whole webpage

See this to learn how to adjust it to your needs: https://timezonedb.com/references/get-time-zone

Btw to find more of such services you can google "free API"
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
I just wanna know how make cleo limited time work only, so i think best way is read time from website ,because nobody can't change it.
 
Status
Not open for further replies.
Top