下载网页数据 请教一下大家,怎么样才能把一个网页中的表格数据下载后保存到数据库中,如有代码,非常感谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比较简单的是用webbrowser控件。也有其它可用控件。不用控件也可以实现。如果需要别人给你写现成的代码,可能要支付一定费用。 TWebBrowser最近好多人在问这个问题啊unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHtml;type TForm1 = class(TForm) wb1: TWebBrowser; Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin wb1.Navigate('http://localhost:12880/mtm/abc.htm');end;procedure TForm1.Button1Click(Sender: TObject);var doc: IHTMLDocument2; mTable: IHTMLTable; mRow: IHTMLTableRow; mCell: IHTMLElement; mElement: IHTMLElementCollection; i,j: integer;begin doc := wb1.Document as IHTMLDocument2; mTable := doc.all.item('xxxx',0) as IHTMLTable; for i:=0 to mTable.rows.length-1 do begin mRow := mTable.rows.item(i,0) as IHTMLTableRow; for j:=0 to mRow.cells.length-1 do begin mCell := mRow.cells.item(j,0) as IHTMLElement; showmessage(mCell.innerHTML); end; end;end;end. 同意三楼 这个有什么难得 我现在做的如火纯青了 最好用idhttp get 可以做成多线程我的程序 可批量下载 那速度搜搜的 不建议使用 webbrowser 用过的应该知道 争夺焦点问题 浪费更多的网络流量速度慢而且你想隐藏 它 还要有技巧 不能直接visible:=false; webbrowser 不可见时 很多事件是无法触发的 建议 httpwatch+idhttp 天下无敌 用IdHttp下载源码→用正则表达式提取数据→插入数据库。 idhttp不知道现在是不是炉火纯青了? dephi怎么获取局域网某台机的D盘目录 50分求教一个QReport问题! 请求高人 谁有delphi7类结构图和好的delphi参考手册。 一直提示“Invalid pointer operation” 关于EOT文件! comboBox控件问题,恼火中……(在线等待) 用WebBrowser实现另存的功能 请问怎么用DELPHI实现小型WEB服务端 支持超文本就可以了,谢谢帮助 鼠标托动效果如何实现? 关于从数个表中取数据的问题。 Delphi+MapX求助!!! 如何向浏览器正在打开的网页中插入并运行代码?
最近好多人在问这个问题啊
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHtml;type
TForm1 = class(TForm)
wb1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
wb1.Navigate('http://localhost:12880/mtm/abc.htm');
end;procedure TForm1.Button1Click(Sender: TObject);
var
doc: IHTMLDocument2;
mTable: IHTMLTable;
mRow: IHTMLTableRow;
mCell: IHTMLElement;
mElement: IHTMLElementCollection;
i,j: integer;
begin
doc := wb1.Document as IHTMLDocument2; mTable := doc.all.item('xxxx',0) as IHTMLTable;
for i:=0 to mTable.rows.length-1 do
begin
mRow := mTable.rows.item(i,0) as IHTMLTableRow; for j:=0 to mRow.cells.length-1 do
begin
mCell := mRow.cells.item(j,0) as IHTMLElement;
showmessage(mCell.innerHTML);
end;
end;
end;end.
争夺焦点问题
浪费更多的网络流量
速度慢而且你想隐藏 它 还要有技巧 不能直接visible:=false; webbrowser 不可见时 很多事件是无法触发的
建议 httpwatch+idhttp 天下无敌