Kurs akcji na GPW

  • 0 Odpowiedzi
  • 3753 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
Kurs akcji na GPW
« dnia: Marzec 25, 2015, 09:42:08 pm »
HC2 = Net.FHttp("www.bankier.pl", 80);
response, status, errorCode = HC2:GET("/inwestowanie/profile/quote.html?symbol=PKOBP");
if tonumber(status) < 400 then
  --fibaro:debug(response..", "..status..", "..errorCode);
  p = string.find(response, "profilLast", 1);
  res = string.sub(response, p+12, p+17);
  res = string.gsub(res, ",", ".");
  fibaro:debug(res);
  local popres = fibaro:getValue(353, "ui.Label2.value");
  if popres == nil then popres = res end
  fibaro:call(353, "setProperty", "ui.Label2.value", res); 
  local mempopres = tonumber(popres);
  local memres = tonumber(res);
  local warres = math.abs(mempopres - memres);
  warres = math.floor(warres*100);
  fibaro:debug("różnica: "..warres);
  Kom = "Wartość jednostki giełdowej banku pe ka o be pe, obecnie wynosi: "..memres.."złotych"
  if mempopres > memres and warres ~= 0 then
    Kom = Kom..". Wartość zmalała o "..warres.."groszy";
  elseif popres < res and warres ~= 0 then
    Kom = Kom..". Wartość wzrosła o "..warres.."groszy";
  else
    Kom = Kom..". Wartość kursu jednostki nie uległa zmianie.";
  end 
 [color=red] fibaro:setGlobal("Komunikat", Kom);
  fibaro:call(333, "pressButton", "2");[/color] <- to moja gadaczka
else
  fibaro:debug("error: "..errorCode..", status: "..status);
end 
Jacek