dephi采集程序代码
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.
评论
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.
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;
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;
发表评论
- 浏览: 22299 次
- 性别:

- 来自: 珠海

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
DELPHI VCL组件 TTreeList ...
没有安装成功: Compile 时报 File not find:'bmp.r ...
-- by newchina -
vsftpd的配置
useradd -d 目录 用户名 passwd 用户 chown 用户名 ...
-- by kenter1643 -
delphi中登录窗体完美实现 ...
工程文件 program stuResult; use ...
-- by kenter1643 -
delphi一些制作外挂知识
几乎没有实战的意义。
-- by kaki -
Delphi技巧
DELPHI加注册表自启动的最简单代码 uses registry; var ...
-- by kenter1643






评论排行榜