Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 22-10-2012
Avatar de kotai
kotai kotai is offline
Miembro
 
Registrado: mar 2004
Ubicación: Gandia
Posts: 31
Poder: 0
kotai Va por buen camino
Si, sigo usando Delphi 2006.

De todas formas ya lo solucioné, importé el ActiveX "Microsoft HTML Object Library" que me hizo un MSHTML_TLB.pas con la clase IHTMLDocument2 que también permite leer el código fuente de los frames:

Código Delphi [-]
//******************************************************************************

function GetBrowserForFrame(Doc: IHTMLDocument2; nFrame: Integer): IWebBrowser2;
var
   pContainer: IOLEContainer;
   enumerator: ActiveX.IEnumUnknown;
   nFetched: PLongInt;
   unkFrame: IUnknown;
   hr: HRESULT;
begin
     Result := nil;
     nFetched := nil;
     // Cast the page as an OLE container
     pContainer := Doc as IOleContainer;
     // Get an enumerator for the frames on the page
     hr := pContainer.EnumObjects(OLECONTF_EMBEDDINGS or OLECONTF_OTHERS, enumerator);
     if hr <> S_OK then
     begin
          pContainer._Release;
          Exit;
     end;
     // Now skip to the frame we're interested in
     enumerator.Skip(nFrame);
     // and get the frame as IUnknown
     enumerator.Next(1,unkFrame, nFetched);
     // Now QI the frame for a WebBrowser Interface - I'm not  entirely
     // sure this is necessary, but COM never ceases to surprise me
     unkframe.QueryInterface(IID_IWebBrowser2, Result);
end;

//******************************************************************************

function GetFrameSource(WebDoc: iHTMLDocument2): string;
  //returns frame HTML and scripts as a text string
var
   re: integer;
   HTMLel: iHTMLElement;
   HTMLcol: iHTMLElementCollection;
   HTMLlen: Integer;
   ScriptEL: IHTMLScriptElement;
begin
     Result := '';
     if Assigned(WebDoc) then
     begin
          HTMLcol := WebDoc.Get_all;
          HTMLlen := HTMLcol.Length;
          for re := 0 to HTMLlen - 1 do
          begin
               HTMLel := HTMLcol.Item(re, 0) as iHTMLElement;
               if HTMLEl.tagName = 'HTML' then
                  Result := Result + HTMLEl.outerHTML;
          end;
     end;
end;

//******************************************************************************

procedure TF_Principal.ObtenerHTML(Num:SmallInt);
var
  Webdoc, HTMLDoc: ihtmldocument2;
  framesCol: iHTMLFramesCollection2;
  FramesLen: integer;
  pickFrame: olevariant;
  p: integer;
  HTML : String;
  iFrame : IWebBrowser2;
begin
     if WB <> nil then
        try
           WebDoc := WB.Document as IHTMLDocument2;
           HTML := GetFrameSource(WebDoc);
           // analizamos el HTML de la página principal
           AnalizarHTML(HTML);
           FramesCol := WebDoc.Get_frames;
           FramesLen := FramesCol.Get_length;
           if FramesLen > 0 then
              for p := 0 to FramesLen - 1 do
              begin
                   pickframe := p;
                   HTMLDoc   := WB.Document as iHTMLDocument2;
                   iFrame    := GetBrowserForFrame(HTMLDoc, pickframe);
                   if iFrame <> nil then
                   begin
                        WebDoc := iFrame.document as iHTMLDocument2;
                        if WebDoc <> nil then
                        begin
                             HTML := GetFrameSource(WebDoc);
                             // analizamos el HTML de este frame
                             AnalizarHTML(HTML);
                        end;
                   end;
              end;
        except
        end;
end;

Saludos.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
TSocketConnection y error "Interface not supported" Aldo Providers 1 13-03-2008 17:52:29
Delphi 5.0 / Firebird 2.0 - Error: Interface not supported RicardoG Conexión con bases de datos 0 19-10-2007 17:39:12
"connection rejected by remote interface" Gigabyte1024 Conexión con bases de datos 3 29-08-2007 06:27:48
JVCL "No personalities supported" vtdeleon Varios 1 10-09-2006 22:01:44
Method "elquesea" not supported by automation object mercury2005 Providers 0 08-12-2004 22:22:29


La franja horaria es GMT +2. Ahora son las 00:49:16.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi