如题。。
用过迅雷的或者快车的都应该知道,他们都有一个功能--下载所有链接。假如我们通过获取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实现抓取这个连接

解决方案 »

  1.   

    1,DELPHI取得的源代碼是包含這些鏈接的,這是提取的結果自己在保存的時候去重就行了
    ------------------------------------------
    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
      

  2.   

    TO devhp 有些连接还是不能分析出来啊。例如http://going.qyun.net在顶部有一则广告(明星斗地主)他的连接大概是http://www.9lianmeng.com/iclk/au=.xxxxxxxxxxxxxxxxxxxxxxxxxxxxtargeturl
    但是你给方法不能分析出来啊。迅雷却可以,鼠标移上去IE也能提示这个连接。求解
      

  3.   

     Tmp:='';
     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测试通过。
      

  4.   

    TO duduxia 
    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;
      

  5.   

    JavaScript连接需要找框架页面,至少要400分才能帖。