unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R dfm}
procedure TForm1Button1Click(Sender: TObject);
var
i: Integer;
begin
webbrowser1Navigate(edit1Text);
end;
procedure TForm1WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
i:integer;
begin
for i := 0 to Webbrowser1OleObjectDocumentlinksLength - 1 do
Listbox1ItemsAdd(Webbrowser1OleObjectDocumentLinksItem(i));
end;
end
利用ClipboardasText; 利用UNICODE格式解决非英文字符的乱码问题
procedure SetClipboardText(AStr: string);
var // SetBuffer(CF_TEXT, PChar(Value)^, Length(Value) + 1);
Data: THandle;
DataPtr: Pointer;
Size: Integer;
WStr: PWideChar;
begin
Size := Length(AStr) 4;
WStr := AllocMem(Size);
try
// convert to Unicode
StringToWideChar(AStr, WStr, Size);
OpenClipboard(0);
EmptyClipboard;
Data := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, Size);
try
DataPtr := GlobalLock(Data);
try
Move(WStr^, DataPtr^, Size);
SetClipboardData(CF_UNICODETEXT, Data);
finally
GlobalUnlock(Data);
end;
except
GlobalFree(Data);
raise;
end;
finally
CloseClipboard;
FreeMem(WStr);
end;
end;
其实你还可以用id>
不要用ID>
以上就是关于如何用Delphi程序抓取一个网站下的所有网页全部的内容,包括:如何用Delphi程序抓取一个网站下的所有网页、DELPHI 如何提取网页事件中的值、怎样用delphi 获取网页html源代码(网页需登录)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)