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

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 17-08-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Seguro que usando un TWebbrowser se pueden ir recorriendo cada una de las etiquetas (aunque yo no se como ), o quizá utilizando algún parser. Pero una forma sencilla de hacerlo es obtener la pagina, colocarla en un string, buscar la etiqueta textarea y copiar lo que se encuentra entre la etiqueta de apertura y de cierre. Algo así:

Código Delphi [-]
program gettext;

{$APPTYPE CONSOLE}

uses
  Windows, SysUtils, WinInet;


function Bajar(Url: string): String;
var
  hNet: HINTERNET;
  hUrl: HINTERNET;
  Buffer: array[0..10240] of Char;
  BytesRead: Cardinal;
begin
  Result := '';
  hNet := InternetOpen('agent', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if (hNet <> nil) then
  begin
    hUrl := InternetOpenUrl(hNet, PChar(Url), nil, 0,
      INTERNET_FLAG_RELOAD, 0);
    if (hUrl <> nil) then
    begin
      FillChar(Buffer,Sizeof(Buffer),0);
      while (InternetReadFile(hUrl, @Buffer, sizeof(Buffer), BytesRead)) do
      begin
        if (BytesRead = 0) then
          break;
        Result:= Result + String(PChar(@Buffer));
        FillChar(Buffer,Sizeof(Buffer),0);
      end;
      InternetCloseHandle(hUrl);
    end;
    InternetCloseHandle(hNet);
  end;
end;

function ObtenerTexto(Url: string; Etiqueta: string): string;
var
  Str: string;
  i: integer;
begin
  Result:= '';
  // Bajamos la pagina
  Str:= Bajar(Url);
  // Buscamos la etiqueta
  i:= Pos(Uppercase(Etiqueta), Uppercase(Str));
  if i > 0 then
  begin
    // Buscamos el final de la etiqueta
   while (Copy(Str,i,1)<>'>') and (i<Length(Str)) do
      inc(i);
   inc(i);
   // Copiamos el texto hasta encontrar otra etiqueta
   while (Copy(Str,i,1)<>'<') and (i<Length(Str)) do
   begin
      Result:= Result + Copy(Str,i,1);
      inc(i);
   end;
  end;
end;

begin
  Writeln(ObtenerTexto('http://www.mipagina.com/index.html','<textarea'));
  readln;
end.

Última edición por seoane fecha: 17-08-2006 a las 14:58:35.
Responder Con Cita
 



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
Descargar Formulario monicasierrar OOP 8 29-09-2005 18:25:25
Descargar DBE brandolin Conexión con bases de datos 4 15-05-2004 03:07:21
Descargar correo pepe2000 Internet 1 17-02-2004 15:54:40
descargar una extencion migueilichenco Internet 1 28-11-2003 21:23:50
Descargar Firebird.. LucasArgentino Tablas planas 1 17-11-2003 14:58:04


La franja horaria es GMT +2. Ahora son las 23:51:54.


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