Foros del Web » Programando para Internet » ASP Clásico »

funcion split

Estas en el tema de funcion split en el foro de ASP Clásico en Foros del Web. la funciona split. es para limitar el contenido de una etiqueta? yo quiero recoger de la cadena: cadena = <img src="images/imagen1" alt="imagen del mundo"> quiero ...
  #1 (permalink)  
Antiguo 29/12/2004, 19:11
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 23 años, 1 mes
Puntos: 8
funcion split

la funciona split.

es para limitar el contenido de una etiqueta?

yo quiero recoger de la cadena:

cadena = <img src="images/imagen1" alt="imagen del mundo">

quiero recoger images/imagen1

se puede hacer con la funcion split?

gracias
  #2 (permalink)  
Antiguo 29/12/2004, 22:21
Avatar de TurKa  
Fecha de Ingreso: enero-2003
Ubicación: Gerli, Avellaneda
Mensajes: 543
Antigüedad: 22 años, 3 meses
Puntos: 4
Se me ocurre que si la cadena tendrá siempre el mismo formato sí, pero sino no estaría tan segura de los resultados.

Si tiene siempre el mismo esquema: <img src ..... alt ...>
podría ser algo así:

<%
cadena = "<img scr=""images/imagen1.jpg"" alt=""imagen del mundo"">"
imagen = Split(cadena,chr(34))
Response.Write imagen(1)
%>

Fíjate si te es útil.
__________________
Programación LAMP con Scrum y XP
www.eugeniabahit.com.com.ar
  #3 (permalink)  
Antiguo 30/12/2004, 03:20
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 23 años, 1 mes
Puntos: 8
si pero...

Si pero es que la cadena es toda una pagina web


que la tengo en una variable


y todo el texto de la pagina web es


<body>
todo lo que tiene una web

</body>

y lo que quiero es recorrer todo el codigo i buscar imagenes y otras cosas
  #4 (permalink)  
Antiguo 30/12/2004, 04:38
Avatar de PMP
PMP
 
Fecha de Ingreso: febrero-2003
Ubicación: Chacabuco - Buenos Aires
Mensajes: 214
Antigüedad: 22 años, 2 meses
Puntos: 1
Fijate si esto te sirve.

Código:
Dim cadena
Dim arrayCadena
Dim I

cadena = "<img scr=""images/imagen1.jpg"" alt=""imagen del mundo"">"

arrayCadena = Split(cadena, chr(34))

For I = 0 to Ubound(arrayCadena)
    If InStr(arrayCadena(I), ".jpg") then
        Response.write(arrayCadena(I))
    end if
Next
Saludos
  #5 (permalink)  
Antiguo 30/12/2004, 04:56
Avatar de Muzztein  
Fecha de Ingreso: agosto-2002
Ubicación: Hangar 18
Mensajes: 1.703
Antigüedad: 22 años, 8 meses
Puntos: 16
una expresion regular te serviria mas.
  #6 (permalink)  
Antiguo 30/12/2004, 06:22
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
^engonga^ creo que aqui encontraras lo que buscas,
se trata de una expresion regular, como te ha dicho Muzztein.

http://www.4guysfromrolla.com/webtech/073000-1.shtml

¿Me podrias decir como haces para tener toda la pagina web en una cadena?
  #7 (permalink)  
Antiguo 30/12/2004, 07:08
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 23 años, 1 mes
Puntos: 8
el codigo

Código HTML:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<%
dim cadena
cadena = Request.QueryString("cadena")
if cadena="" then
cadena = "http://paginaweb.com"
end if

Response.Buffer = True
Dim objXMLHTTP, xml

' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

' Opens the connection to the remote server.
xml.Open "GET", cadena, False
' Actually Sends the request and returns the data:
xml.Send

'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
Response.Write xml.responseText
Response.Write "</xmp>"

Response.Write "<p><hr><p><h1>The HTML Output</h1>"
' supongo que el xml.responseText se puede poner dentro de una cadena no?
Response.Write xml.responseText
%>
</body>
</html>

lo dicho




  #8 (permalink)  
Antiguo 30/12/2004, 10:48
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
He probado el codigo pero obtengo un error:

Si uso:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
El error es:
msxml3.dll error '800c0008'
The download of the specified resource has failed.

Si uso:
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
El error es:
msxml3.dll error '80072ee2'
The operation timed out
He intentado con este error cambiar el Session.Timeout con un valor alto, pero sigue apareciendo.

¿Alguna idea?
  #9 (permalink)  
Antiguo 30/12/2004, 14:46
Avatar de TurKa  
Fecha de Ingreso: enero-2003
Ubicación: Gerli, Avellaneda
Mensajes: 543
Antigüedad: 22 años, 3 meses
Puntos: 4
Me parece que la opción que te dió PMP, es la más sencilla y acertada. Solo indica otras extensiones de imagen y listo.

Fíjate si haces la prueba con esto, funciona a la perfección:

<%
Dim cadena
Dim arrayCadena
Dim I

cadena = "<body><p>Hola Mundo</p><p><img scr=""images/imagen1.jpg"" alt=""imagen del mundo""></p><hr><img scr=""images/imagen2.gif"" alt=""imagen del mundo 2""></p></body>"

arrayCadena = Split(cadena, chr(34))

For I = 0 to Ubound(arrayCadena)
If InStr(arrayCadena(I), ".jpg") OR InStr(arrayCadena(I), ".gif") then
Response.write(arrayCadena(I) & "<br>")
end if
Next
%>
__________________
Programación LAMP con Scrum y XP
www.eugeniabahit.com.com.ar
  #10 (permalink)  
Antiguo 30/12/2004, 16:27
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 23 años, 1 mes
Puntos: 8
problema del servidor

sqa212


puede ser que en tu servidor no tengas instalado este componente prueva con esto

Código PHP:
<% @ Language="VBScript" %>
<% 
Option Explicit %>
<%
' there are a number of objects that come with IIS4
these are put in the array that's declared below
Dim theInstalledObjects(9)

theInstalledObjects(0) = "MSWC.AdRotator"
theInstalledObjects(1) = "MSWC.BrowserType"
theInstalledObjects(2) = "MSWC.NextLink"
theInstalledObjects(3) = "MSWC.Tools"
theInstalledObjects(4) = "MSWC.Status"
theInstalledObjects(5) = "MSWC.Counters"
theInstalledObjects(6) = "IISSample.ContentRotator"
theInstalledObjects(7) = "IISSample.PageCounter"
theInstalledObjects(8) = "MSWC.PermissionChecker"
theInstalledObjects(9) = "Microsoft.XMLHTTP"

Function IsObjInstalled(strClassString)
On Error Resume Next
initialize default values
IsObjInstalled 
False
Err 
0
' testing code
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
cleanup
Set xTestObj 
Nothing
Err 
0
End 
Function
%>

<
HTML>
<
HEAD>
<
TITLE>Test of installed objects</TITLE>
</
HEAD>
<
BODY>

Enter the ProgId or ClassId of the component you want to test in the textbox below. If you leave it empty, the default
components will be tested.

productes:
theInstalledObjects(0) = "MSWC.AdRotator"<br>
theInstalledObjects(1) = "MSWC.BrowserType"<br>
theInstalledObjects(2) = "MSWC.NextLink"<br>
theInstalledObjects(3) = "MSWC.Tools"<br>
theInstalledObjects(4) = "MSWC.Status"<br>
theInstalledObjects(5) = "MSWC.Counters"<br>
theInstalledObjects(6) = "IISSample.ContentRotator"<br>
theInstalledObjects(7) = "IISSample.PageCounter"<br>
theInstalledObjects(8) = "MSWC.PermissionChecker"<br><br><br>

<
FORM action=<%=Request.ServerVariables("SCRIPT_NAME")%> method=post>
<
input type=text value="" name="classname" size=40>
<
INPUT type=submit value=Submit>
<
INPUT type=reset value=Reset
</
FORM>

<%
Dim strClass
strClass 
Trim(Request.Form("classname"))
If 
"" <> strClass then
Response
.Write strClass " is "
If Not IsObjInstalled(strClassthen 
Response
.Write "<strong>not installed</strong>"
Else
Response.Write "installed!"
End If
Response.Write "<P>" vbCrLf
Else
 default: list 
all components that should be installed
%>

<
TABLE BORDER=0>
<%
Dim i
For i=0 to UBound(theInstalledObjects)
Response.Write "<TR><TD>" theInstalledObjects(i) & "</TD><TD>"
If Not IsObjInstalled(theInstalledObjects(i)) Then 
Response
.Write "<strong>not installed</strong>"
Else
Response.Write "installed!"
End If
Response.Write "</TD></TR>" vbCrLf
Next
%>
</
TABLE

esto te dice que componentes tienes instalados en tu servidor


espero que te sirva
  #11 (permalink)  
Antiguo 31/12/2004, 01:09
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
Gracias ^engonga^
Me aparece que esta instalado el componente "Microsoft.XMLHTTP"
Estoy usando un servidor en brinkster Premium.
¿Alguien sabe que ocurre?

Turka con tu codigo obtengo este error:
Error de compilación de Microsoft VBScript (0x800A0409)
Constante de cadena sin terminar
/webpesca/extraer.asp, línea 15, columna 67
cadena = "<body><p>Hola Mundo</p><p><img scr=""images/imagen1.jpg""

Última edición por sqa212; 31/12/2004 a las 03:58
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:54.