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 07-10-2008
Avatar de Faust
Faust Faust is offline
Miembro
 
Registrado: abr 2006
Ubicación: México D.F.
Posts: 930
Poder: 19
Faust Va por buen camino
Saber si está arriba una URL

Espero no estar abriendo un hilo con un tema ya discutido anteriormente.

La cuestión es esta: necesito monitorear cuando ya esté levantada cierta página de internet, p. ej.

Saber si "https://servidor.com.mx/directorio" me direcciona a su página por default, en este caso sería "https://servidor.com.mx/directorio/index.html" y no me devuelve un error "404 Not Found".

No me he metido mucho en esto de internet, agradecería cualquier ayuda.
__________________
Herr Heins Faust
Responder Con Cita
  #2  
Antiguo 29-10-2008
Fistandantilus Fistandantilus is offline
Miembro
 
Registrado: ago 2008
Posts: 10
Poder: 0
Fistandantilus Va por buen camino
Fijate si esto te sirve.

tenes q meter la libreria WinInet

Código Delphi [-]
function TPreferencesForm.GetURLStatus(aURL: String): Integer;
var
   hInet, hConecction, httprequest: HINTERNET;
   Host, Page: String;
   size, Reserved: Cardinal;
   Head: Array [0..1024] of Char;
begin
   Result := -1;
   Reserved := 0;
   hInet := nil;
   hConecction := nil;
   httprequest := nil;
   if (aURL <> '') then begin
      try
         hInet := InternetOpen('lo q kieras', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
         if Assigned(hInet) then begin
            AnsiReplaceStr(aURL, 'http://', '');
            if (Pos('/', aURL) > 0) then begin
               Host := Copy(aURL, 1, Pos('/', aURL)-1);
               Page := Copy(aURL, Pos('/', aURL)+1, Length(aURL));
            end else begin
               Host := aURL;
               Page := '';
            end;
            hConecction := InternetConnect(hInet, PAnsiChar(Host), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
            if Assigned(hConecction) then begin
               HttpRequest := HttpOpenRequest(hConecction, 'HEAD', PAnsiChar(Page), nil, nil, nil, INTERNET_FLAG_KEEP_CONNECTION, 0);
               if Assigned(HttpRequest) then begin
                  if (HttpSendRequest(HttpRequest, nil, 0, nil, 0)) then begin
                     size := SizeOf(Head);
                     HttpQueryInfo(HttpRequest, HTTP_QUERY_STATUS_CODE, @Head, size, reserved);
                     if (String(Head) <> '') then begin
                        try
                           Result := StrToInt(String(Head));
                        except
                           Result := -6;
                        end;
                     end else begin
                        Result := 0;
                     end;
                  end else begin
                     Result := -5;
                  end;
               end else begin
                  Result := -4;
               end;
            end else begin
               Result := -3;
            end;
         end else begin
            Result := -2;
         end;
      finally
         if Assigned(hInet) then InternetCloseHandle(hInet);
         if Assigned(hConecction) then InternetCloseHandle(hConecction);
         if Assigned(HttpRequest) then InternetCloseHandle(HttpRequest);
      end;
   end;

end;

Espero q te sirva

saludos
Responder Con Cita
  #3  
Antiguo 31-10-2008
Avatar de Faust
Faust Faust is offline
Miembro
 
Registrado: abr 2006
Ubicación: México D.F.
Posts: 930
Poder: 19
Faust Va por buen camino
Gracias por tu respuesta amigo...

Ya hasta me había olvidado de este hilo .

En cuanto pueda lo pruebo...
__________________
Herr Heins Faust
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
Saber si archivo esta en uso Lina API de Windows 3 09-06-2008 18:08:47
Saber si el audio esta en uso b3nshi Varios 1 02-04-2008 01:24:32
Saber si se esta ejecutando un EXE en mi PC lcardcont API de Windows 2 08-06-2007 19:57:42
saber si esta php instalado coulthard Internet 4 20-04-2006 19:56:43
Saber si esta conectado Kaesbu Internet 1 22-09-2003 14:09:45


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


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