Hola...
Cita:
Empezado por cocute
He probado a quitar los memos y poner 2 tstringlist pero no me funciona, no hace nada, tambien he probado con Tstrings pero me da "error abtracto" o algo asi.
Que puede fallar? el mismo código con memos funciona.
Código PHP:
procedure TForm1.FormActivate(Sender: TObject);
var ind,tt:integer;
file1,file2:TStringlist;
begin
file1:= TStringlist.create;
file2:= TStringlist.create;
file1.text:=idHttp1.Get('http://www.aemet.es/es/eltiempo/prediccion/localidades?l=22080');
for ind := 0 to file1.Count-1 do
begin
if file1.ValueFromIndex[ind]='<h2 class="titulo">' then
begin
for tt := ind to file1.Count-1 do
begin
file2.Add(file1.ValueFromIndex[tt]);
if file1.ValueFromIndex[tt]=' <form name="frmMunicipio" method="get" action="/es/eltiempo/prediccion/localidades">' then
begin
file2.ValueFromIndex[0]:= '<link rel="stylesheet" type="text/css" media="screen" href="http://www.aemet.es/css/estilos.css" /><h2 class="titulo">';
file2.text:= StringReplace( file2.text,'/imagenes/','http://www.aemet.es/imagenes/',[rfReplaceAll]);
wb1.LoadFromStrings(file2);
file1.Free;
file2.Free;
exit
end;
end;
end;
end;
end;
|
Checando este código con el que pusiste usando el
TMemo, veo que es muy diferente. Aquí una versión usando
TStringList:
Código Delphi
[-]
var
Web: TStringList;
Temp: TStringList;
ind: Integer;
tt: Integer;
begin
Web := TStringList.Create;
Temp := TStringList.Create;
try
Web.Text := idHttp1.Get('http://www.aemet.es/es/eltiempo/prediccion/localidades?l=22001');
for ind := 0 to Pred(Web.Count) do
if Web[ind] = '< h2 class="titulo" >' then
for tt := ind to Pred(Web.Count) do
begin
Temp.Add(Web[tt]);
if Web[tt] = ' < form name="frmMunicipio" method="get" ' +
'action="/es/eltiempo/prediccion/localidades" >' then
begin
Temp[0] := '< link rel="stylesheet" type="text/css" media="screen" ' +
'href="http://www.aemet.es/css/estilos.css" / >< h2 class="titulo" >';
Temp.Text := StringReplace(Temp.Text, '/imagenes/',
'http://www.aemet.es/imagenes/', [rfReplaceAll]);
wb1.LoadFromStrings(Temp);
Exit
end
end
finally
Web.Free;
Temp.Free
end
end;
Saludos...
P.D.
TString es una clase abstracta y es por eso que cuando quieres instanciar un objeto de esa clase obtienes el error
"abstracto"