您的位置:程序门 -> delphi -> windows sdk/api



获取已经在ie中打开的网页的源代码


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


获取已经在ie中打开的网页的源代码[已结贴,结贴人:lgl0769]
发表于:2007-12-13 20:57:04 楼主
一个网页已经在ie中打开了,可以通过ie的菜单查看源代码。

重新用这个网址去获取源代码的话,由于网站的限制,会重新出现登录的画面。

所以要求不能再用那个网址去get源代码。

有个getiesource的软件可以实现这个功能,但是想在自已的程序中查看这个网页的源代码。请问在delphi中怎么实现?
发表于:2007-12-13 21:27:331楼 得分:5
delphi(pascal) code
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); if 0 = hhtmltext then exit;// raiselastwin32error; 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;
发表于:2007-12-13 22:16:422楼 得分:0
多谢回复,再问一下如何把打开的ie窗口作为上述函数的参数来调用?
发表于:2007-12-13 23:41:193楼 得分:15
给你一个例子吧
下载这个
发表于:2007-12-14 00:08:574楼 得分:0
谢谢了,先结贴了,再慢慢学习。
发表于:2007-12-19 11:53:075楼 得分:0
是做自动顶帖机?


快速检索

最新资讯
热门点击