如题。。
用过迅雷的或者快车的都应该知道,他们都有一个功能--下载所有链接。假如我们通过获取HTML源码来分析出连接,那么js里面的连接获取不到!问题详细说明:
1、假如我们打开了http://www.google.cn/
2、假如我们已经获取了HTML源代码
3、假如我们要获取“视频”这个链接地址(迅雷下载所有连接可以得到,或者鼠标移到“视频”处,IE下方有提示)
http://www.google.cn/url?ct=pro&cd=0&source=cwh&q=http%3A%2F%2Fvideo.google.cn%2F4、问题出现:在我们获取的HTML源代码中不会出现这个链接,而我们的鼠标移到“视频”上,下方有提示这个连接
5、我们应该怎么用Delphi实现抓取这个连接
用过迅雷的或者快车的都应该知道,他们都有一个功能--下载所有链接。假如我们通过获取HTML源码来分析出连接,那么js里面的连接获取不到!问题详细说明:
1、假如我们打开了http://www.google.cn/
2、假如我们已经获取了HTML源代码
3、假如我们要获取“视频”这个链接地址(迅雷下载所有连接可以得到,或者鼠标移到“视频”处,IE下方有提示)
http://www.google.cn/url?ct=pro&cd=0&source=cwh&q=http%3A%2F%2Fvideo.google.cn%2F4、问题出现:在我们获取的HTML源代码中不会出现这个链接,而我们的鼠标移到“视频”上,下方有提示这个连接
5、我们应该怎么用Delphi实现抓取这个连接
解决方案 »
- 如何在panel上面加的Image 上画东西呢?
- 在imageen控件中,如何设置扫描得分辨率和图像类别(比如,8位灰度),解决立即给分,
- 使用INDY出现 cannot allocate stocket错误怎么解决啊?
- 请问怎么做闹钟程序啊,有什么好的建议吗??
- 求共享软件加密算法?急!!!
- 此为不做家务全攻略(男生版) ^_^
- 有没有高手,怎么就没人知道??????????200分,不够再加!!!
- 请问关于如何将query里的查询结果导为EXECL文件
- 还是MDI窗体问题?高手请指点!
- 问一个关于创建临时的问题.
- 用Tmemorystream写入任意10进制的十六进制问题。
- windows与linux使用socket通信的问题
------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
imgsrc :string;
begin
for i :=1 to wb.OleObject.Document.links.Length - 1 do begin
imgsrc := wb.OleObject.document.links.item(i).href;
if ansicontainstext(imgsrc,'google') then
else
if memo1.Lines.IndexOf(imgsrc)=-1 then memo1.Lines.Add(imgsrc); end;end;
------------------------------------------------------
相關信息
http://hi.baidu.com/szba/blog/item/9a0e5c1eed0431fc1bd57697.htmlMemo1http://www.265.com/?hl=zh-CN&tab=vA
http://www.tudou.com/programs/view/r3t4vOVJ0ug/
http://6.cn/watch/11104620.html
http://www.tudou.com/programs/view/1sslcduqSdQ/
http://v.ku6.com/show/sxZc0OcCJT48QqSo.html
http://6.cn/watch/11102481.html
http://v.ku6.com/show/O8ixoRLQsRl15q79.html
http://v.ku6.com/show/OjOg1VffvOZmtMEu.html
http://info.smgbb.cn/zixun/yule/2009-04-04/141672.html
http://v.ku6.com/show/L1qMphgiOazBKfTS.html
http://you.joy.cn/video/389144.htm
http://v.blog.sohu.com/u/vw/2536782
http://www.tudou.com/programs/view/AOwsFWlNUok/
http://video.sina.com.cn/ent/v/m/2009-04-06/005938593.shtml
http://play.hupo.tv/tv/167454.html
http://v.youku.com/v_show/id_XODM1OTcxMzY=.html
http://video.sina.com.cn/ent/m/c/2009-04-03/135238467.shtml
http://6.cn/watch/11047495.html
http://video.sina.com.cn/ent/y/2009-04-06/224738624.shtml
但是你给方法不能分析出来啊。迅雷却可以,鼠标移上去IE也能提示这个连接。求解
with (WebBrowser.Document as IHTMLDocument2).body.all as IHTMLElementCollection do
for i:=0 to length-1 do
with item(i,i) as IHTMLElement do
if AnsiSameText(WideCharToString(PWideChar(tagName)),'A') then
with item(i,i) as IHTMLAnchorElement do begin
Tmp:=Tmp+Format('文本:%s (%4d,%4d) - (%4d,%4d) [%4d x %4d]]',[WideCharToString(PWideChar(innerText)),offsetLeft,offsetTop,offsetWidth+offsetLeft,offsetHeight+offsetTop,offsetWidth,offsetHeight])+CRLF;
Tmp:=Tmp+Format('%s',[WideCharToString(PWideChar(href))])+CRLF;
end;
StringToFileA('超级链接.txt',AnsiString(Tmp));Delphi2009测试通过。
CRLF和StringToFileA编译的时候有点问题。所以修改了一下,D7测试通过。
但是js里面的连接仍然不能列出来。等待解决
uses
MSHTML;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
Tmp:string;
begin
Tmp:='';
with (WebBrowser1.Document as IHTMLDocument2).body.all as IHTMLElementCollection do
for i:=0 to length-1 do
with item(i,i) as IHTMLElement do
if AnsiSameText(WideCharToString(PWideChar(tagName)),'A') then
with item(i,i) as IHTMLAnchorElement do
begin
Tmp:=Tmp+Format('文本:%s (%4d,%4d) - (%4d,%4d) [%4d x %4d]]',[WideCharToString(PWideChar(innerText)),offsetLeft,offsetTop,offsetWidth+offsetLeft,offsetHeight+offsetTop,offsetWidth,offsetHeight])+#10{+CRLF};
Tmp:=Tmp+Format('%s',[WideCharToString(PWideChar(href))])+#10{+CRLF};
end;
//StringToFileA('超级链接.txt',AnsiString(Tmp)); ListBox1.Items.Add(Tmp); ListBox1.Items.SaveToFile('超级链接.txt'); end;