Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/08/2009, 01:48
Avatar de luisvasquez
luisvasquez
 
Fecha de Ingreso: diciembre-2003
Ubicación: Venezuela
Mensajes: 879
Antigüedad: 21 años, 4 meses
Puntos: 6
Guardar imágen con MSXML2.ServerXMLHTTP

Estimados amigos de FDW,

Estoy intentando crear una función en ASP para guardar imágenes a partir de su URL. Pienso que se puede hacer con MSXML2.ServerXMLHTTP pero no he logrado encontrar info al respecto. A ver si me dan una mano.


Tengo una función que me trae un HTML dado un URL

Código:
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", "text/html"
    objXMLHTTP.SetRequestHeader "charset", "iso-8859-1" 
    objXMLHTTP.Send
    if objXMLHTTP.statusText="OK" then
        GetHTML = objXMLHTTP.responseBody
   else
        Response.write "Error en página:" & objXMLHTTP.statustext
   end if
    Set objXMLHTTP = Nothing
End Function

' con una simple instrucción puedo mostrar en mi web la URL dada

response.write(GetHTML("http://www.forosdelweb.com"))
Ahora bien, esta función coloca el HTML en una variable, pero tengo varias preguntas.

¿Qué tal si quiero guardar el HTML y no simplemente mostrarlo?

¿Y si la URL no es un HTML sino una imágen?

Agradezco lo que puedan hacer por mí.

Saludos,
Luis Vásquez