有没有API或者其他方法,实现直接从浏览器中获取到网页信息,然后进行相应的数据操作!
求指点

解决方案 »

  1.   

    请问如果用IdHTTP进行GET()和POST()的话,在浏览器中已经被打开的网页是否能同步更新到
      

  2.   

    在浏览器中已经被打开的网页 必须 自动或程序操作地 刷新一下不使用webbrowser,关键是无法得到js执行后的效果
      

  3.   

    找个WireShark抓包。
    不开WEBBROWSER 用Indy模拟,json,js什么都搞定。
      

  4.   

    可以使用idhttp来处理,你下载个HttpAnalyzerStdV6抓下包,过滤出来有效的http步骤,然后模拟就好了
      

  5.   

    function TfrmMain.GetXXXXXXXXXStatus(const xh: string; out xx, zylb, qdh, zysj,
      ch, hph, fz, dz, zt: string): Boolean;
    var
      PostParams :TStrings;
      s ,Html:string;
      Match :TMatch;
      IndyHttp :TIdHttp;
      IndyCookieManager :TIdCookieManager;
      IndyZlib: TIdCompressorZLib;
    begin
      xx :='';
      zylb :='';
      qdh :='';
      zysj :='';
      ch :='';
      hph :='';
      fz :='';
      dz :='';
      zt :='';
      Randomize;
      Result :=True;
      PostParams :=TStringList.Create;  IndyHttp :=TIdhttp.Create(nil);
      IndyCookieManager :=TIdCookieManager.Create(nil);
      IndyZlib :=TIdCompressorZLib.Create(nil);
      try
        try
          //配置参数
          IndyHttp.CookieManager :=IndyCookieManager;
          IndyHttp.Compressor :=IndyZlib;
          IndyHttp.Disconnect;
          IndyHttp.HandleRedirects :=False;
          IndyHttp.AllowCookies :=True;
          IndyHttp.Request.CustomHeaders.Clear;
          IndyHttp.HTTPOptions :=[hoForceEncodeParams];
          IndyHttp.Request.Accept :='text/html, application/xhtml+xml, */*';
          IndyHttp.Request.AcceptEncoding :='';
          IndyHttp.Request.AcceptLanguage :='zh-CN';
          IndyHttp.Request.CacheControl :='no-cache';
          IndyHttp.Request.Connection :='Keep-Alive';
          IndyHttp.Request.UserAgent :='Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';      IndyHttp.Request.Host :='XXXXXXXXXXXXXXXXXX';
          IndyHttp.Request.Referer :='XXXXXXXXXXXXXXXXXXXXXXXX.jsp';
          IndyHttp.Request.ContentType :='application/x-www-form-urlencoded';      PostParams.Add('number1='+xh);
          PostParams.Add('number2=');
          PostParams.Add('number3=');
          PostParams.Add('number4=');
          PostParams.Add('number5=');
          PostParams.Add('Submit=确定');
          Html :=IndyHttp.Post('http://XXXXXXXXXXXXXXXXXX.jsp',PostParams);
          //sl.SaveToFile('D:\111.html');
          //sl.LoadFromFile('D:\111.html');
          s :=Copy(xh,1,4);
          s :=s + ' ' +Copy(xh,5,7);
          s := s+ '(?:.*\r?\n){4}.*?>(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){5} *(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){4}.*?>(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){5} *(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){3}.*?>(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){3}.*?>(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){5} *(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){4} *(.*?) *\r?\n';
          s := s+ '(?:.*\r?\n){4}.*?>(.*?) *\r?\n';
          Match :=TRegEx.Match(Html,s,[roMultiLine]);
          if Match.Success then
          begin
            xx :=Match.Groups[1].Value;
            zylb :=Match.Groups[2].Value;
            qdh :=Match.Groups[3].Value;
            zysj :=Match.Groups[4].Value;
            ch :=Match.Groups[5].Value;
            hph :=Match.Groups[6].Value;
            fz :=Match.Groups[7].Value;
            dz :=Match.Groups[8].Value;
            zt :=Match.Groups[9].Value;
          end;
          Delay(Random(2000)+1000);
        except
          Result :=False;
        end;
      finally
        PostParams.Free;
        IndyHttp.Disconnect;
        IndyHttp.Free;
        IndyCookieManager.Free;
        IndyZlib.Free;
      end;
    end;
      

  6.   

    不是非用WebBrowser才得到内容。可以从IE中直接获取窗口Handle,然后获取Com+ Shell.Application获取IWebBrowser接口,就可以直接操作,js执行后的结果同样能得到。
      

  7.   

    自己写很难哦,你能自己写浏览器内核了。
    你找不到需要填写数据的地方,或者是一个textbox或者是一个combbox.
    WebBrowser使用的是IE的内核,你看看源代码,只引用写了多少行?
    自动网页填充数据也必须是在网页已经打开的情况下完成的。
      

  8.   

    怎么没有人提到IHTMLDocument2呢?虽然执行效率比idhttp低,但很实用。
      

  9.   

    现在就是用的IHTMLDocument2,先是通过CreateOleObject创建一个对象实现的!
      

  10.   


    var
      IE: Variant;
      Doc:IHTMLDocument2;
      InputEle: IHTMLInputElement;begin
      IE := CreateOleObject('InternetExplorer.Application');
      IE.Visible := True;
      IE.Navigate('C:\Test.html');  Doc := (IDispatch(IE.document) as IHTMLDocument2); 
      if Doc=nil then exit;
      InputEle:=(Doc.all.item('A204098',0) as IHTMLInputElement);
      InputEle.Value := 'TestText';
    end;
    最后实现处理