如题,最好大家能给一个例子!谢谢!!

解决方案 »

  1.   

    大家给看看我写的有什么问题,(刚学,希望大家多多指点!)谢谢!!
    #########线程###########
    type
      TWebThread = class(TThread)
      private
         webbrowser:TWebBrowser;
         number:integer;
         Fminnum,Fmaxnum:integer;
         Fhost:string;
      protected
        procedure Execute; override;
        procedure WebBrowserDocumentComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
        function seturl:string;
      public
      published
        constructor Create(minnum,maxnum:integer);
        destructor Destroy; override;
      end;
    implementation
     uses unit1;
    constructor twebthread.Create(minnum,maxnum:integer);
    begin
     inherited Create(True);   
      FreeOnTerminate:=true;     
      Fminnum:=minnum;
      Fmaxnum:=maxnum;
      Suspended:=False;        end;
    destructor TwebThread.Destroy;
    begin
       CoUninitialize;
      inherited destroy;
    end;
    procedure TWebThread.Execute;
    begin
     try
         CoInitialize(nil);
         webbrowser:=TWebbrowser.Create(nil);
         Fhost:=seturl;
         form1.memo2.text:=form1.memo2.text+fhost;
         webbrowser.Navigate(Fhost);
         webbrowser.OnDocumentComplete:=WebBrowserDocumentComplete;
         while not Terminated do
          Application.ProcessMessages;
      finally
        webbrowser.Free;
      end;
    end;
    function TWebThread.seturl:string;
    begin
        url:='http://www.google.com.sg/search?q=+%22%E5%A8%B1%E4%B9%90%E5%A4%A7%E7%www.epic.com&hl=zh-CN&lr=&newwindow=1&as_qdr=all&start='+inttostr(Fminnum)+'&sa=N';
        Fminnum:=Fminnum+10;
        result:=url;
    end;
    procedure Twebthread.WebBrowserDocumentComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
    var
    doc:IHTMLDocument2;
    all:IHTMLElementCollection;
    len,i:integer;
    item:OleVariant;
    begin
       if not webbrowser.busy then
       begin
          doc:=webbrowser.Document as IHTMLDocument2;
          all:=doc.Get_Links;
          len:=all.length;
         for i:=0 to len-1 do
           begin
             item:=all.item(i,varempty);
            if (pos('google',item)=0)and(pos('hl=zh-CN',item)=0)and(pos('article_',item)>0) then
              form1.Memo1.Lines.Add(item);
           end;
       end;
    end;
    end.#######调用#####
    procedure TForm1.Button7Click(Sender: TObject);
    var
    j:integer;
    th:array[0..5] of twebthread;
    begin
    minnum:=strtoint(form1.Edit1.text) ;
    maxnum:=strtoint(form1.Edit2.text);
    for j:=0 to 3 do
    begin
     th[j]:=twebthread.Create(minnum,maxnum) ;
      minnum:=minnum+10;
      if minnum>=maxnum then
      break;
    end;
    end;  
      

  2.   

    Twebbrowser实际上是封装了浏览器控件,也就是说,它需要一个OLE容器才可以正常工作。如果你仅需要一个无界面的HTML分析器,可以直接创建一个IE的HTMLDocument对象,或者自己写一个浏览器。参考http://msdn.microsoft.com/archive/en-us/samples/internet/browser/walkall/default.asp
    http://developer.mozilla.org/en/docs/Download_Mozilla_Source_Code
      

  3.   

    同意楼上,如果你想做一个分析器,建议自己用SocketAPI写吧,很容易。socket connect send recv close 一般常用的就这几个函数。
    HTTP协议也简单GET /文件路径 HTTP/1.1
    Host: 主机名(xxxx.com)+两个回车(#13#10#13#10)
      

  4.   

    托起来,我也在做类似的东西
    jiangsheng(蒋晟.Net)说的东西就是我要的
    但是两个例子都是c的,看得晕啊,有delphi的吗?