Krótkie wiadomości codziennie - RSS

  • 1 Odpowiedzi
  • 11983 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

*

Offline Jacek

  • *** 117
  • 3
  • Nazwa i wersja ID: HC2 4.130, HC2 3.600, HCL 4.100
Krótkie wiadomości codziennie - RSS
« dnia: Marzec 25, 2015, 09:46:11 pm »
function jakiez(str)
  newStr = ""
  il = string.len(str);
  for i = 1 , il do
    chr = string.sub(str, i, i);
    byte = string.byte(chr);
    --[[if byte > 128 then
      if i % 2 == 0 then
        fibaro:debug(i..", "..", "..byte.." - "..chr)
      end 
    end  --]]
    if byte == 179 then     chr = "\ł"
    elseif byte == 243 then chr = "\ó" 
    elseif byte == 241 then chr = "\ń"
    elseif byte == 177 then chr = "\ą"
    elseif byte == 234 then chr = "\ę"
    elseif byte == 191 then chr = "\ż"
    elseif byte == 182 then chr = "\ś"
    elseif byte == 230 then chr = "\ć"
    elseif byte == 188 then chr = "\ź"
 
    elseif byte == 129 then chr = "\Ł"
    elseif byte == 147 then chr = "\Ó" 
    elseif byte == 131 then chr = "\Ń"
    elseif byte == 132 then chr = "\Ą"
    elseif byte == 152 then chr = "\Ę"
    elseif byte == 187 then chr = "\Ż"
    elseif byte == 154 then chr = "\Ś"
    elseif byte == 134 then chr = "\Ć"
    elseif byte == 189 then chr = "\Ź"

    end
    newStr = newStr..chr
  end
  return newStr
end 

HC2 = Net.FHttp("wiadomosci.wp.pl", 80);
response, status, errorCode = HC2:POST("/rss.xml", "");
if tonumber(errorCode) == 0 then
  if tonumber(status) < 400 then
    respon = response
    fibaro:setGlobal("Komunikat", "Przedstawie krótkie informacje.");
    fibaro:call(333, "pressButton", "2");
    fibaro:sleep(3000);
    while true do 
      p = string.find(respon, '<!', 1);
      if p == nil then break end
      respon = string.sub(respon, p, -1);
      p1 = string.find(respon, "/>", 1 );
      if p1 == nil then break end
      respon = string.sub(respon, p1+2, -1);
      p2 = string.find(respon, "<a", 1 );
      if p2 == nil then break end
      resp = string.sub(respon, 1, p2-1);
      resp = jakiez(resp);
      --fibaro:debug(resp);
      ilzn = string.len(resp);
     [color=red] fibaro:setGlobal("Komunikat", resp);
      fibaro:call(333, "pressButton", "2");[/color] <- moja gadaczka
      fibaro:sleep((ilzn/12)*900);
      respon = string.sub(respon, p2+2, -1)
    end 
    fibaro:setGlobal("Komunikat", "Koniec krótkich informacji.");
    fibaro:call(333, "pressButton", "2");
  else
    fibaro:debug("status: "..status    );
  end   
else
  fibaro:debug("error: "..errorCode..", status: "..status);
end 
Jacek
Odp: Krótkie wiadomości codziennie - RSS
« Odpowiedź #1 dnia: Styczeń 29, 2019, 08:06:40 pm »
Witam serdecznie
Mogę poprosić o dokładniejszy opis jak to zrobić by otrzymywać krótkie wiadomości RRS ?