请教不通过网页原代码获取网页内所有URL的方法  注意是不通过网页原代码  最好有现成的函数或者组件

解决方案 »

  1.   

    上个帖子已经回复过你了,请注意查看。
    //可以枚举所有的网页链接,然后循环取出即可。 
    //已经调试通过,注意:要在uses里引用mshtml单元。 
    //使用的控件:WebBrowser1,ListBox1和一个按钮
    //下面是代码: 效果图见下图:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      doc: IHTMLDocument2;
      all: IHTMLElementCollection;
      len, i: integer;
      item: OleVariant;
    begin
      doc := WebBrowser1.Document as  IHTMLDocument2;
      all := doc.links;
      len := all.length;
      for i := 0 to len-1 do
      begin
          item := all.item(i, varempty);
          if ListBox1.Items.IndexOf(item.href) = -1   then
          begin
              ListBox1.Items.Append(item.href);
          end;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      WebBrowser1.Navigate('www.china.com');
    end;
      

  2.   

    上面的代码是获取所有的超级链接,如果楼主需要网页里面所有的URL的话可能麻烦一点。