WebBrowser 获取网页内容
2014-01-15 16:09
267 查看
1.wb.OleObject.document.documentelement.innerhtml
2.utf8toansi(getHtml(wb))
utf8toansi函数
function getHtml(const
WebBrowser:TWebBrowser):string;
const
BufSize = $10000;
var
Size: Int64;
Stream: IStream;
hHTMLText: HGLOBAL;
psi: IPersistStreamInit;
begin
if not Assigned(WebBrowser.Document) then
Exit;
OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit,pSi));
try
hHTMLText :=
GlobalAlloc(GPTR,BufSize);
OleCheck(CreateStreamOnHGlobal(hHTMLText,True,Stream));
try
OleCheck(Psi.Save(Stream,False));
Size := StrLen(PChar(hHTMLText));
SetLength(Result,Size);
CopyMemory(PChar(Result),Pointer(hHTMLText),Size);
finally
Stream := nil;
end;
finally
pSi :=
nil;
end;
end;
2.utf8toansi(getHtml(wb))
utf8toansi函数
function getHtml(const
WebBrowser:TWebBrowser):string;
const
BufSize = $10000;
var
Size: Int64;
Stream: IStream;
hHTMLText: HGLOBAL;
psi: IPersistStreamInit;
begin
if not Assigned(WebBrowser.Document) then
Exit;
OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit,pSi));
try
hHTMLText :=
GlobalAlloc(GPTR,BufSize);
OleCheck(CreateStreamOnHGlobal(hHTMLText,True,Stream));
try
OleCheck(Psi.Save(Stream,False));
Size := StrLen(PChar(hHTMLText));
SetLength(Result,Size);
CopyMemory(PChar(Result),Pointer(hHTMLText),Size);
finally
Stream := nil;
end;
finally
pSi :=
nil;
end;
end;
相关文章推荐
- 使用phantomjs&casperjs+jsoup获取网页内容
- 获取网页内容(不登录_PHP&.NET)
- C#获取网页内容 (WebClient、WebBrowser和HttpWebRequest/HttpWebResponse)
- 黄聪:C#里如何使用WebBrowser获取处理AJAX生成的网页内容?
- 获取html中 title标签里的内容
- 黄聪:C#里如何使用WebBrowser获取处理AJAX生成的网页内容?
- jsp 后台获取checkbox里的值,不用…
- httpclient 获取网页内容
- 三种方法:C#获取网页内容
- 手机服务 & BroadcastReceiver & 获取电池相关内容
- 【C#】获取网页内容及HTML解析器HtmlAgilityPack的使用
- 定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容
- 获取网页内容
- Vector为 JTable 赋值 获取表 值
- jquery 获取父窗口的元素 父窗口 …
- 获取网页中的内容(CDHtmlDialog)
- httpclient 用java调用 的方式获取网页内容,
- VC++获取某个http网页内容
- C#用正则表达式获取网页中制定位置的内容
- js 获取服务器控件的值