http://www.paginas-web.com.ar/cgi-bi...l?Mode=Agregar
le das una url y te da el titulo y la descripción.
mirando codigo llama una subrutina perl.
Se puede hacer esto en asp?
| |||
Se puede hacer esto en asp? http://www.paginas-web.com.ar/cgi-bi...l?Mode=Agregar le das una url y te da el titulo y la descripción. mirando codigo llama una subrutina perl. Se puede hacer esto en asp? |
| |||
Si, con la funcion que he puesto mas abajo lees el contenido de la pagina y lo dejas en una cadena. Luego tendrias que analizar la cadena con (con instr) extrayendo (con mid) lo que esta entre <TITLE> y </TITLE> para el titulo, y lo que esta en la propiedad content de <META name="Description" content="..."> Function GetHTML(strURL) as string Dim objXMLHTTP, strReturn, strHTML Set objXMLHTTP = SErver.CreateObject("MSXML2.ServerXMLHTTP") objXMLHTTP.Open "GET", strURL, False objXMLHTTP.Send strHTML = objXMLHTTP.responseText Set objXMLHTTP = Nothing return strHTML End Function
__________________ |
| |||
gracias, por tu ayuda. se puede obtener el titulo y la descripcion de una forma más limpia, sin tener q utilizar funciones de tratamiento de cadenas? no se existen fuciones Xml que faciliten el proceso? Última edición por rrufo; 29/07/2004 a las 02:27 |
| |||
Function GetText(strText, strStartTag, strEndTag) dim intStart intStart = instr(1, strText, strStartTag, vbtextcompare) if intStart then intStart = intStart + len(strStartTag) intEnd = InStr(intStart + 1, strText, strEndTag, vbtextcompare) GetText = Mid(strText, intStart + 1, intEnd - intStart - 1) else GetText = " " end if End Function |
| |||
Sobre lo primero, puedes usar algun parser, como este por ejemplo: http://www.cimarronravine.com/products/ParseHTML/ lastimosamente es pago. Es mas sencillo y barato es manejarte con cadenas. Lo de los acentos tiene que ver con la codificacion... aqui se discute el problema y pegan algo de codigo: http://dbforums.com/arch/195/2003/2/676676
__________________ |
| |||
he entradopara dar la solución, lo unico q en algunos caso el tema va mut lento. Function GetHTML(strURL) Dim objXMLHTTP, strReturn, strHTML Set objXMLHTTP = SErver.CreateObject("MSXML2.ServerXMLHTTP") objXMLHTTP.Open "GET", strURL, False objXMLHTTP.setRequestHeader "Accept-Language", "sp" objXMLHTTP.setRequestHeader "Pragma", "no-cache" objXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objXMLHTTP.SetRequestHeader "Content-Type", "text/html" objXMLHTTP.SetRequestHeader "charset", "iso-8859-1" objXMLHTTP.Send if objXMLHTTP.statusText="OK" then body8209 = objXMLHTTP.responseBody GetHTML = "" For i = 0 to UBound(body8209) GetHTML = GetHTML & chrw(ascw(chr(ascb(midb(body8209,i+1,1))))) Next else Response.write "Error en página:" & objXMLHTTP.statustext end if Set objXMLHTTP = Nothing End Function |