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,'&nbsp;',' ',[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,'&nbsp;',' ',[rfReplaceAll]);
Label3.Caption:='日均 IP 访问量:'+s;

 

 


end;


    end.

评论
kenter1643 2007-10-15
unit Unit1;

interface

uses
SysUtils, Types, Classes, Variants, QTypes, QGraphics, QControls, QForms,
QDialogs, QStdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;

type
TForm1 = class(TForm)
Edit1: TEdit;
IdHTTP1: TIdHTTP;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
procedure FormCreate(Sender: TObject);
private
function cha(ss:string;ee:string;re:string):string;
{ Private declarations }

public
{ Public declarations }

end;

var
Form1: TForm1;
re,s,ss,ee : string;


implementation

{$R *.xfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
//adoconnection1.Connected:=false;
//adoconnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+ ExtractFilePath(Application.ExeName) +'\Unit.DAT;Mode=Share Deny None;Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:SFP=False';
//adoconnection1.Connected:=true;
re:=IdHTTP1.Get('http://fund.eastmoney.com/360005.html');
Edit1.Text := cha('<title>','主页_天天基金网</title>',re);
edit2.Text := cha('公布净值:<font color="#000000">','元</font>',re);
edit3.Text := cha('padding-left:10px">投资风格:','   类型',re);
edit4.Text := cha('申购费率上限:<font color="#000000">','</font>',re);
edit5.Text := cha('赎回费率上限:<font color="#000000">','</font>',re);
edit6.Text := cha('  状态:','</td></tr>',re);
edit7.Text := cha('10px">基金经理:','</font>',re);
edit8.Text := cha(' 基金管理人:',' ',re);
edit9.Text := cha(' 基金托管人:','</td>',re);
end;

function TForm1.cha(ss:string;ee:string;re:string):string;
var
stt:string;
begin
stt:=copy(re,pos(ss,re)+Length(ss),99);
stt:=copy(stt,1,pos(ee,stt)-1);
result :=stt;
end;

end.
kenter1643 2007-10-13
re:=IdHTTP1.Get('http://alexa.chinaz.com/?domain=tttz.com');
ss:='<td width="174" align="left">';

s:=copy(re,pos(ss,re)+Length(ss),99999);
s:=copy(s,1,pos('</td>',s)-1);
Edit1.Text := s;
kenter1643 2007-10-13
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;
发表评论

您还没有登录,请登录后发表评论

kenter1643
搜索本博客
博客分类
最近加入圈子
存档
最新评论