本帖最后由 obaby 于 2010-3-9 09:35 编辑
unit ip;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP,OleCtrls,ComObj ;
type
TForm1 = class(TForm)
mmo1: TMemo;
Button1: TButton;
edt1: TEdit;
lbl1: TLabel;
idhtp: TIdHTTP;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
xml : OleVariant;
r:string;
p1,p2 : Integer;
I:Integer;
begin
xml := CreateOleObject('Microsoft.XMLHTTP');
xml.Open('GET','http://www.123cha.com/ip/?q='+edt1.Text, False);
xml.Send;
r := xml.responseText;
p1:=Pos('数据</font>',r);
p2:=Pos('<li>[查询提供]',r);
mmo1.lines.add(' 您查询的地址可能归属地是:') ;
mmo1.lines.add(' ===========================') ;
mmo1.Lines.add (Copy(r, p1+16, p2-p1-5));
mmo1.Text:=StringReplace(mmo1.Text,' ','',[rfReplaceAll]);
mmo1.Text:=StringReplace(mmo1.Text,'</li>','',[rfReplaceAll]);
mmo1.Text:=StringReplace(mmo1.Text,'<li>','',[rfReplaceAll]);
mmo1.Text:=StringReplace(mmo1.Text,'<font color="blue">','',[rfReplaceAll]);
mmo1.Text:=StringReplace(mmo1.Text,'</font>','',[rfReplaceAll]);
end;
Project1.rar
(463.02 KB, 下载次数: 0)
补上编译后的exe。 |