Mis estimados amigos, investigando logre dar con la solucion, chequeen el codigo:
Código Delphi
[-]
function ObtenerWeb(webIP : string) : string;
var
Response: TStringStream;
HTTP: TIdHTTP;
begin
Result := '';
Response := TStringStream.Create('');
try
HTTP := TIdHTTP.Create(nil);
try
HTTP.Get(webIP, Response);
if HTTP.ResponseCode = HTTP_RESPONSE_OK then begin
Result := Response.DataString;
end else begin
end;
finally
HTTP.Free;
end;
finally
Response.Free;
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
doc: OleVariant;
el: OleVariant;
i: Integer;
HTML:string;
begin
with TIdHTTP.Create(nil) do
try
HTML:=ObtenerWeb('http://www.sbs.gob.pe/0/modulos/jer/jer_interna.aspx?are=0&pfl=0&jer=147');
doc := coHTMLDocument.Create as IHTMLDocument2;
doc.write(HTML);
doc.close;
for i := 0 to doc.body.all.length - 1 do
begin
el := doc.body.all.item(i);
if (el.tagName = 'P') and (el.className = 'WEB_compra') then
ShowMessage(el.innerText);
if (el.tagName = 'P') and (el.className = 'WEB_venta') then
ShowMessage(el.innerText);
end;
finally
Free;
end;
end;
Ahora, surje lo siguiente: Internet es muy lento en mi ciudad, por lo tanto, al pulsar este boton todo el programa se queda congelado, quisiera preguntar de que forma puedo realizar esta consulta en otro Thread de ejecucion, tal cual trabaja Ajax con sus llamadas asincronas...
Un abrazo a todos
Americo