Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/02/2003, 16:38
RakoVky
 
Fecha de Ingreso: diciembre-2002
Mensajes: 100
Antigüedad: 22 años, 4 meses
Puntos: 1
Error en SPIDER

Hey MAESTROS prueben este pequeño SPIDER.

Funciona de la siguiente manera:

al colocar una url en el Formulario, este script visita la página y extrae información de ella, luego le da salida.

me da un error cuando la URL no existe......

Como corregirian este error???.....

Espero que puedan entender esto


Consta de dos scrip ASP.

Primero:

<<<<<<<<<<<"spider.asp">>>>>>>>>>>>>>>>
<%
dim HTTP, url
url=Request.Form("url")
'url="http://www.sgi.com/homepage.html"
set HTTP=Server.CreateObject("Microsoft.XMLHTTP")
HTTP.open "GET", url , False
HTTP.Send
stu=HTTP.statusText
if HTTP.statusText="OK" then
strFileContents = HTTP.ResponseText
else
Response.write "Error obteniendo Página " & HTTP.statustext
end if
set HTTP = nothing


%>
<%
Dim key1, key2, errorkey, errordes

strFileContents = replace(strFileContents, "<meta name=keywords", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME=keywords", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME=keywords", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME=KEYWORDS", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name=keywords", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name=KEYWORDS", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME=KEYWORDS", "<meta name=""keywords""")

strFileContents = replace(strFileContents, "<meta name='keywords'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME='keywords'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME='keywords'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME='KEYWORDS'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name='keywords'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name='KEYWORDS'", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME='KEYWORDS'", "<meta name=""keywords""")

strFileContents = replace(strFileContents, "<meta name=""keywords""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME=""keywords""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME=""keywords""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META NAME=""KEYWORDS""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name=""keywords""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<META name=""KEYWORDS""", "<meta name=""keywords""")
strFileContents = replace(strFileContents, "<meta NAME=""KEYWORDS""", "<meta name=""keywords""")

strFileContents = replace(strFileContents, "<meta name=description", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME=description", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME=description", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME=DESCRIPTION", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name=description", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name=DESCRIPTION", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME=DESCRIPTION", "<meta name=""description""")

strFileContents = replace(strFileContents, "<meta name='description'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME='description'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME='description'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME='DESCRIPTION'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name='description'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name='DESCRIPTION'", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME='DESCRIPTION'", "<meta name=""description""")

strFileContents = replace(strFileContents, "<meta name=""description""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME=""description""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME=""description""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META NAME=""DESCRIPTION""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name=""description""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<META name=""DESCRIPTION""", "<meta name=""description""")
strFileContents = replace(strFileContents, "<meta NAME=""DESCRIPTION""", "<meta name=""description""")

strFileContents = replace(strFileContents, "<TITLE>", "<title>")
strFileContents = replace(strFileContents, "</TITLE>", "</title>")

if InStr(1, strFileContents, "<meta name=""keywords""",1) > 0 then
key1 = InStr(1, strFileContents, "<meta name=""keywords""", 1)
key1 = key1 + Len("<meta name=""keywords""")
key2 = InStr(key1, strFileContents, """>", 1)

keywords = Trim(Mid(strFileContents, key1, (key2 - key1)))

keywords = Replace (keywords, "content=""", "")
keywords = Replace (keywords, "CONTENT=""", "")
keywords = Replace (keywords, "content=", "")
keywords = Replace (keywords, "CONTENT=", "")
keywords = Replace (keywords, "content='", "")
keywords = Replace (keywords, "CONTENT='", "")

Dim desc1, desc2
if InStr(1, strFileContents, "<meta name=""description""",1) > 0 then
desc1 = InStr(1, strFileContents, "<meta name=""description""", 1)
desc1 = desc1 + Len("<meta name=""description""")
desc2 = InStr(desc1, strFileContents, """>", 1)

descripcion = Trim(Mid(strFileContents, desc1, (desc2 - desc1)))

descripcion = Replace (descripcion , "content=""", "")
descripcion = Replace (descripcion , "CONTENT=""", "")
descripcion = Replace (descripcion , "content=", "")
descripcion = Replace (descripcion , "CONTENT=", "")
descripcion = Replace (descripcion , "content='", "")
descripcion = Replace (descripcion , "CONTENT='", "")

if InStr(1, strFileContents, "<title>",1) > 0 then

tit1 = InStr(1, strFileContents, "<title>", 1)
tit1 = tit1 + Len("<title>")
tit2 = InStr(tit1, strFileContents, "</title>", 1)
titulo = Trim(Mid(strFileContents, tit1, (tit2 - tit1)))
titulo = Replace (titulo, "'", " ")

if keywords <> "" then
response.Write("<strong>pagina Indexable</strong><br><br>")
response.Write("<strong>"+stu+"</strong><br><br>")
response.Write(keywords)
response.Write("<br><br>")
response.Write(descripcion)
response.Write("<br><br>")
response.Write(titulo)
else
response.Write("pagina No Indexable")
'response.Write("<br><br>")
end if
end if
end if
end if
'set HTTP = nothing
%>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<p>&nbsp;</p>
<p>
</p>
<table width="450" border="0">
<tr>
<td><form name="form1" method="post" action="spider.asp">
<input name="url" type="text" id="url" value="http://" size="55">
<input type="submit" name="Submit" value="Indexar">
</form></td>
</tr>
</table>
</BODY>
</HTML>
<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>

Segundo:

<<<<<<<<<<<<<"default.asp">>>>>>>>>>>>>>>>>>>>>>
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="450" border="0">
<tr>
<td><form action="spider.asp" method="post" name="form" id="form">
<input name="url" type="text" id="url" value="http://" size="55">
<input type="submit" name="Submit" value="Indexar">
</form></td>
</tr>
</table>
</body>
</html>
<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>