Delphi中提取网页源代码


本文整理自网络,侵删。

 1.用idhttp
const
URL = 'http://www.3464.com';
begin
memo1.lines.text := idhttp1.get(URL);
end;
2.用webbrowser
//只获取到内的源码
const
URL = 'http://www.4936.cn';
begin
webbrowser1.Navigate(URL);
while WebBrowser1.Busy do
    Application.ProcessMessages;
memo1.lines.Text := WebBrowser1.OleObject.document.documentElement; 
end;
//获取全部源码
uses ActiveX;
const
URL = 'http://www.521.com';
var
ms: TMemoryStream;
begin
WebBrowser1.Navigate(URL);
while WebBrowser1.Busy do
    Application.ProcessMessages;
ms := TMemoryStream.Create;
try
    (WebBrowser1.Document as IPersistStreamInit).Save(TStreamAdapter.Create(ms), True);
    ms.Position := 0;
    Memo1.Lines.LoadFromStream(ms);
finally
    FreeAndNil(ms);
end;
end;

相关阅读 >>

Delphi 为 service application 添加描述文本的方法

Delphi 通过指点操作获得窗口句柄

Delphi中进行指纹仪的二次开发

Delphi firemonkey 绘图

Delphi中如何向某个ip不间断的发送数据

Delphi hexstrtobytes

Delphi streamtohexstr

Delphi 取最前窗口标题(不重复)

Delphi源码 基础源码-连接数据库,验证登录信息

Delphi 时间耗时统计

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...