Jump to content

How to get data from a website with ams?


NickStels

Önerilen İletiler

 

function string:split(delimiter)
    local result = { }
    local from  = 1
    local delim_from, delim_to = string.find( self, delimiter, from  )
    while delim_from do
        table.insert( result, string.sub( self, from , delim_from-1 ) )
        from  = delim_to + 1
        delim_from, delim_to = string.find( self, delimiter, from  )
    end
    table.insert( result, string.sub( self, from  ) )
    return result
end
HTTP.DownloadSecure("www.unixtimestamp.com", "AutoPlay//Docs//veri.txt", MODE_BINARY, 20, 443, nil, nil, nil);
t2 = TextFile.ReadToString("AutoPlay//Docs//veri.txt")
tab = String.Between(t2,'<td>20','+00:00</td>')
for i,v in pairs(tab)do
Ttab= v:split("T");
ct = String.TrimLeft(v, Ttab[1].."T");
end
Ttab2= Ttab[1]:split("-");
Tct= ct:split(":");
h=Tct[1]+4
m=Tct[2]
Label.SetText("Label1",'date'..' '..Ttab2[3]..'-'..Ttab2[2]..'-'..Ttab2[1]..' '..'time'..' '..h..':'..m);

 

Thank you. Good example. Tell me, is it possible to work with the luacurl library? on the Internet I found an example of its work in AMS, but by this time the files are no longer available (( Once again Thank you very much.

Yorum bağlantısı
Sitelerde Paylaş

  • Yönetici

I've never used the luacurl library, I don't know if it will work.

Yorum bağlantısı
Sitelerde Paylaş

  • Başlık How to get data from a website with ams? olarak değiştirildi
function string:split(delimiter)
    local result = { }
    local from  = 1
    local delim_from, delim_to = string.find( self, delimiter, from  )
    while delim_from do
        table.insert( result, string.sub( self, from , delim_from-1 ) )
        from  = delim_to + 1
        delim_from, delim_to = string.find( self, delimiter, from  )
    end
    table.insert( result, string.sub( self, from  ) )
    return result
end
HTTP.DownloadSecure("www.unixtimestamp.com", "AutoPlay//Docs//veri.txt", MODE_BINARY, 20, 443, nil, nil, nil);
t2 = TextFile.ReadToString("AutoPlay//Docs//veri.txt")
tab = String.Between(t2,'<td>20','+00:00</td>')
for i,v in pairs(tab)do
Ttab= v:split("T");
ct = String.TrimLeft(v, Ttab[1].."T");
end
Ttab2= Ttab[1]:split("-");
Tct= ct:split(":");
h=Tct[1]+4
m=Tct[2]
Label.SetText("Label1",'date'..' '..Ttab2[3]..'-'..Ttab2[2]..'-'..Ttab2[1]..' '..'time'..' '..h..':'..m);

It turned out that you can do without downloading and function. It may be useful for someone else. 

Yorum bağlantısı
Sitelerde Paylaş

  • Yönetici
NickStels, 2 saat önce yazdı:
result = HTTP.SubmitSecure("https://www.unixtimestamp.com", {}, SUBMITWEB_GET, 20, 443, nil, nil);
v = string.match(result, "<td>20(.-)+00:00</td>");
Ttab= v:split("T");
ct = String.TrimLeft(v, Ttab[1]);
ct = String.TrimLeft(ct,"T");
Ttab2= Ttab[1]:split("-");
Tct= ct:split(":");
h=Tct[1]+4
m=Tct[2]
treg = Ttab2[3]..'-'..Ttab2[2]..'-'..Ttab2[1]..' '..h..':'..m
Dialog.Message("", treg, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

It turned out that you can do without downloading and function. It may be useful for someone else. 

This code gives an error, please, if you have a sample project, can you send it?

Yorum bağlantısı
Sitelerde Paylaş

Falcon, 08.08.2022 - 08:59 yazdı:

This code gives an error, please, if you have a sample project, can you send it?

Sorry, one function I used , online translation difficulties.

function string:split(delimiter)
    local result = { }
    local from  = 1
    local delim_from, delim_to = string.find( self, delimiter, from  )
    while delim_from do
        table.insert( result, string.sub( self, from , delim_from-1 ) )
        from  = delim_to + 1
        delim_from, delim_to = string.find( self, delimiter, from  )
    end
    table.insert( result, string.sub( self, from  ) )
    return result
end
HTTP.DownloadSecure("www.unixtimestamp.com", "AutoPlay//Docs//veri.txt", MODE_BINARY, 20, 443, nil, nil, nil);
t2 = TextFile.ReadToString("AutoPlay//Docs//veri.txt")
tab = String.Between(t2,'<td>20','+00:00</td>')
for i,v in pairs(tab)do
Ttab= v:split("T");
ct = String.TrimLeft(v, Ttab[1].."T");
end
Ttab2= Ttab[1]:split("-");
Tct= ct:split(":");
h=Tct[1]+4
m=Tct[2]
Label.SetText("Label1",'date'..' '..Ttab2[3]..'-'..Ttab2[2]..'-'..Ttab2[1]..' '..'time'..' '..h..':'..m);

I meant that for the search it was not necessary to use the function

result = HTTP.SubmitSecure("https://www.unixtimestamp.com", {}, SUBMITWEB_GET, 20, 443, nil, nil);
v = string.match(result, "<td>20(.-)+00:00</td>");
Dialog.Message("", v, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

 

Yorum bağlantısı
Sitelerde Paylaş

Hello, tell me please how to make a string.match results list? I did using the site headers, but it is not practical. the headlines are different and somewhere they are not at all.I am attaching an example, button 1 gets links, button 2 searches, and I don’t know how to display search results 😞

anime.apz

 

Yorum bağlantısı
Sitelerde Paylaş

Sohbete katıl

Şimdi mesajını gönderebilir ve daha sonra kayıt olabilirsin. Bir hesabın varsa, hesabınla göndermek için şimdi oturum aç.

Misafir
Bu konuyu yanıtla

×   Yapıştırdığınız içerik biçimlendirme içeriyor.   Biçimlendirmeyi Temizle

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Önceki içeriğiniz geri yüklendi.   Editör içeriğini temizle

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Yeni Oluştur...

Önemli Bilgilendirme

KartalSoftware Forum kurallarını okudum ve kabul ettim.