elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Leer pagina web
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Leer pagina web  (Leído 2,584 veces)
Ner0x

Desconectado Desconectado

Mensajes: 14


Ver Perfil
Leer pagina web
« en: 4 Abril 2006, 02:02 am »

Hola todos quisiera xfavor q me dieran un ejemplo de como leer una PARTE de una pagina web por ejemplo si vamos a la pagina web del el mercurio (www.elmercurio.cl) arriba hay una parte que sale: "Santiago de Chile, lunes 3 de abril de 2006, actualizado a las 6:39 hrs." que esto oviamente va cambiando... como hago para leer solo esa parte de la pagina, aunque cambie.
Por favor denme un ejemplo.
Gracias de antemano


En línea

Robokop


Desconectado Desconectado

Mensajes: 1.660



Ver Perfil
Re: Leer pagina web
« Respuesta #1 en: 4 Abril 2006, 04:03 am »

Pues como que para eso necesitarias crear un tipo navegador pero que solamente muestre caracteres y de hay usar la funcion MID para cortar hasta que cantidad de letras quieres leer


En línea

Cicklow


Desconectado Desconectado

Mensajes: 604


-=Cicklow SOFT®=-


Ver Perfil WWW
Re: Leer pagina web
« Respuesta #2 en: 4 Abril 2006, 17:29 pm »

Yo entiendo lo que keres hacer, yo realize un crakeador de webs (de files, osea que busca si existe el index.php, index.asp, etc),  y para eso lo que ice fue leer el codigo fuente de la web, y verificar si existia la palabra error, 404 etc...

Yo para esto use este programa, que me muestra codigos fuentes de las api de windows:
http://www.allapi.net/agnet/appdown.shtml

y use este codigo:
Código:
Const scUserAgent = "API-Guide test program"
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Const sURL = "http://www.microsoft.com/index.htm"
Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net

    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
    'Create a buffer for the file we're going to download
    sBuffer = Space(1000)
    'Create an internet connection
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
    'Open the url
    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
    'Read the first 1000 bytes of the file
    InternetReadFile hFile, sBuffer, 1000, Ret
    'clean up
    InternetCloseHandle hFile
    InternetCloseHandle hOpen
    'Show our file
    MsgBox sBuffer
End Sub

este te dara un ejemplo de como es leer un file en internet en este caso lee los primeros 1000 bytes de la web, www.microsoft.com/index.htm.

ahora para buscar lo que vos keres seria:

Reemplasas
 MsgBox sBuffer
Por
Código:
 If Instr(sBuffer,"Santiago de Chile")>0 Then
   Texto = ""
   For I=Instr(sBuffer,"Santiago") To Len(sBuffer)
     Cadenita = Mid(sBuffer,I,1)
     If Cadenita<>"." Then
      Texto = Texto + Cadenita
     Else
      Exit For
     EndIf
   Next
 End If
 'Esto lo que hace es comenzar a extraer la cadena desde donde encontro santiago, hasta que encuentre un punto.....

Saludos!!!
En línea

www.cicklow.com . Solo Soy Un Ciego que Ve El Sonido Del Silencio
TrOnNe

Desconectado Desconectado

Mensajes: 28



Ver Perfil
Re: Leer pagina web
« Respuesta #3 en: 4 Abril 2006, 20:28 pm »

ciclow, recuerdas q estuvimos hablando sobre los headers en wininet, ok aqui lo publico
Al final un codigo que comprueba una url con apis, no lo hice yo, solo lo adapte para lo que queria.
Sirve para saber si una web existe o no sin bajarse ni los 1000kbs de ciclow, esto solo baja los headers
si quereis saber el tamaño del fichero, podeis cambiar HTTP_QUERY_STATUS_CODE por HTTP_QUERY_CONTENT_LENGTH etc..
para los que no esten muy puestos, necesita 2 capos de texto y un boton, en el primer campo se pone el servidor ejemplo pepitoperez.soy (sin http) y en el segundo la ruta: usuario/micarpeta/mi.doc

Citar
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_DEFAULT_HTTP_PORT = 80
Private Const INTERNET_SERVICE_HTTP = 3
Private Const INTERNET_FLAG_RELOAD = &H80000000
Private Const ERROR_INSUFFICIENT_BUFFER = 122

Private Const HTTP_QUERY_CONTENT_TYPE = 1
Private Const HTTP_QUERY_CONTENT_LENGTH = 5
Private Const HTTP_QUERY_EXPIRES = 10
Private Const HTTP_QUERY_LAST_MODIFIED = 11
Private Const HTTP_QUERY_PRAGMA = 17
Private Const HTTP_QUERY_VERSION = 18
Private Const HTTP_QUERY_STATUS_CODE = 19
Private Const HTTP_QUERY_STATUS_TEXT = 20
Private Const HTTP_QUERY_RAW_HEADERS = 21
Private Const HTTP_QUERY_RAW_HEADERS_CRLF = 22
Private Const HTTP_QUERY_FORWARDED = 30
Private Const HTTP_QUERY_SERVER = 37
Private Const HTTP_QUERY_USER_AGENT = 39
Private Const HTTP_QUERY_SET_COOKIE = 43
Private Const HTTP_QUERY_REQUEST_METHOD = 45


Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, sOptional As Any, ByVal lOptionalLength As Long) As Long
Private Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer



Private Function CheckURL(servidor As String, ruta As String)

Dim sBuffer         As String * 1024
Dim lBufferLength   As Long

p_lInternetSession = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
                                     
m_lInternetConnect = InternetConnect(p_lInternetSession, servidor, INTERNET_DEFAULT_HTTP_PORT, vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)

m_lHttpRequest = HttpOpenRequest(m_lInternetConnect, "HEAD", ruta, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)


If CBool(m_lHttpRequest) Then
    '
    'prepare string buffer to get server response
    '
    lBufferLength = Len(sBuffer)
   
    '
    'send request to remote server. On this state we need Interent connection.
    'If system not connected to Internet, dialog with default RAS entry will
    'be showed
    '
    iRetVal = HttpSendRequest(m_lHttpRequest, vbNullString, 0, 0, 0)
   
    '
    'Use HTTP_QUERY_LAST_MODIFIED flag to try to retrieve value of the LastModified
    'header of the server response. If server has returned LastModified header
    'value of CheckURL will be True and sBuffer will consist value of the header
    '
    valida = CBool(HttpQueryInfo(m_lHttpRequest, HTTP_QUERY_STATUS_CODE, ByVal sBuffer, lBufferLength, 0))
    If sBuffer <> 404 Then
    CheckURL = True
    Else
    CheckURL = False
    End If
   
End If
End Function

Private Sub Command1_Click()
MsgBox CheckURL(Text1.Text, Text2.Text)
End Sub
« Última modificación: 4 Abril 2006, 20:51 pm por tronne » En línea

Cicklow


Desconectado Desconectado

Mensajes: 604


-=Cicklow SOFT®=-


Ver Perfil WWW
Re: Leer pagina web
« Respuesta #4 en: 4 Abril 2006, 23:32 pm »

todo muy bien pero el que pregunto no keria eso el keria ver el codigo fuente y solo sakar una parte del texto (osea una parte del codigo fuente), pero lo que haces vos es ver si existe o no la url!!!!!

mi codigo es el que le serivra para el proposito!
En línea

www.cicklow.com . Solo Soy Un Ciego que Ve El Sonido Del Silencio
TrOnNe

Desconectado Desconectado

Mensajes: 28



Ver Perfil
Re: Leer pagina web
« Respuesta #5 en: 5 Abril 2006, 13:42 pm »

jeje sorry, ni lei el post, solo lei el tuyo y pense q era lo otro, pero bueno, si no le vale a el a nosotros si.
un saludo
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Como leer pagina web
Programación C/C++
Away 2 1,560 Último mensaje 29 Marzo 2017, 15:34 pm
por Away
[PYTHON] Leer pagina web
Scripting
<Trocutor> 2 2,319 Último mensaje 4 Octubre 2017, 02:25 am
por tincopasan
¿Cómo leer manga? Programa o página.
Foro Libre
Tachikomaia 2 2,904 Último mensaje 17 Mayo 2021, 00:18 am
por Tachikomaia
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines