unit Unit1;
interface
uses
Windows,Messages, SysUtils, Forms,
IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, StdCtrls, Controls, Classes, OleCtrls, SHDocVw,
ExtCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Web1: TWebBrowser;
Label6: TLabel;
Edit2: TEdit;
Label4: TLabel;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
re,s,number,left:string;
begin
if edit1.text='' then
begin
messagebox(handle,'请输入需要查询的网站地址!','提示',64);
exit;
end;
number:=trim(edit1.text);
//idhttp1.Get('http://www.cn18.de'); /// 这个意思就是先访问这个页面
//idhttp1.Get('http://alexa.chinaz.com/?domain='+number+''); /// 然后访问这个页面
re:=idhttp1.Get('http://alexa.chinaz.com/?domain='+number+''); /// 最后读取这个页面源代码
left:='<td width="100" align="left"><span id="Rank"><img src="';
s:=copy(re,pos('<td width="100" align="left"><span id="Rank"><img src="',re)+55,99999);
/// +29意思就是前规律的字符数(可以用我提供的软件查) 99999是规律中的截取数据字符。
s:=copy(s,1,pos('" border="0"></span></td>',s)-1);
s:=stringreplace(s,' ',' ',[rfReplaceAll]);
Label1.Caption:='综合排名:'+s; /// s 就是我们截取到的内容
//Image1.Picture.LoadFromFile('http://alexa.chinaz.com/'+s);
s:=copy(re,pos('<td width="174" align="left">',re)+29,99999);
s:=copy(s,1,pos('</td>',s)-1);
Label2.Caption:='收录日期:'+s;
s:=copy(re,pos('<span id="IpNum"><img src="',re)+33,100);
s:=copy(s,1,pos('" border="0"></span>',s)-1);
s:=stringreplace(s,' ',' ',[rfReplaceAll]);
Label3.Caption:='日均 IP 访问量:'+s;
end;
end.