Copiar uma String de uma Pagina HTML

Delphi

17/12/2004

Eu precisava saber como copiar uma string de uma HP...

Exemplo... existe um site que me informa o IP atual no velox ou outros...

Eu precisava copiar este IP pelo Delphi.

Existem dois sites que me informam o IP Atual:

www.meuip.com.br
http://www.modemclub.com.br/cgi-bin/mostraip.cgi


Bom_ba

Bom_ba

Curtidas 0

Respostas

Bom_ba

Bom_ba

17/12/2004

Eu precisava saber como copiar uma string de uma HP...

Exemplo... existe um site que me informa o IP atual no velox ou outros...

Eu precisava copiar este IP pelo Delphi.

Existem dois sites que me informam o IP Atual:

www.meuip.com.br
http://www.modemclub.com.br/cgi-bin/mostraip.cgi
Ai galera... Descobri como: vejam ai:

procedure TForm1.Button1Click(Sender: TObject);
var
InetIP: string;
WebAddress, SearchString: string;
Buff, P, FT: PChar;
BuffLen: Word;
StartPos, StringLength, TempInt: Integer;
begin
WebAddress := ´http://www.whatismyip.com/´;
SearchString := ´Your ip is ´;
Memo1.Clear;
try
NMHTTP1.Get(WebAddress);
except
on E: Exception do
begin
MessageDlg(´Could not get IP Address! ´ +
´Please ensure you are connected to ´ +
´the Internet.´, mtError, [mbOK], 0);
end;
end;
Memo1.Text := NMHTTP1.Body;
Memo1.SelStart := 0;
GetMem(FT, Length(SearchString) + 1);
StrPCopy(FT, SearchString);
BuffLen := Memo1.GetTextLen + 1;
GetMem(Buff, BuffLen);
Memo1.GetTextBuf(Buff, BuffLen);
P := Buff + Memo1.SelStart + Memo1.SelLength;
P := StrPos(P, FT);
if P = nil then MessageBeep(0)
else
begin
Memo1.SelStart := P - Buff;
Memo1.SelLength := Length(SearchString);
end;
StringLength := Memo1.SelLength;
StartPos := Memo1.SelStart + StringLength;
tempint := StartPos;
InetIP := ´´;
while ((Buff[TempInt] in [´0´..´9´]) or
(Buff[TempInt] = ´.´)) do
begin
InetIP := InetIP + Buff[TempInt];
tempint := tempint + 1;
end;
FreeMem(FT, Length(SearchString) + 1);
FreeMem(Buff, BuffLen);
Edit1.Text := InetIP;
end;


GOSTEI 0
POSTAR