'DECLARACION DE VARIABLES '======================== Dim Dim Dim Dim Dim Dim TextoComprobar, TextoExtraido Intervalo max,min errorweb, errormacro, errortext01, errortext02, errortext03 buscatext01, buscatext02, Buscatext03 Timeout 'MAXIMO Y MINIMO DE TIEMPO ENTRE COMPROBACIONES (SEGUNDOS) '========================================================= max = 15 min = 5 'TIEMPO DE ESPERA EN ERRORES (SEGUNDOS) '======================================= Timeout = 5 'TEXTO QUE, DE SER ENCONTRADO EN LA EXTRACCION, SE CONSIDERARA ERROR '=================================================================== errortext01 = "Internet Explorer no puede mostrar la página" errortext02 = "couldn't connect to host" errortext03 = "HTTP 404 No se encontró" 'COMIENZO SCRIPT '================== MsgBox "SE VA A INICIAR LA EXTRACCION INICIAL. UNA VEZ REALIZADA LA EXTRACCION, COMPRUEBA QUE ES CORRECTA" 'CREAMOS OBJETOS '================== set iim1= CreateObject ("imacros") set iim2= CreateObject ("imacros") 'EXTRACCION INICIAL '================== iret = iim1.iimInit() iplay = iim1.iimPlay("extractor") TextoComprobar = iim1.iimGetLastExtract() errormacro = iim1.iimGetLastError() buscatext01 = InStr(1, TextoComprobar, errortext01, vbTextCompare) buscatext02 = InStr(1, TextoComprobar, errortext02, vbTextCompare) buscatext03 = InStr(1, TextoComprobar, errortext03, vbTextCompare) If iplay = 1 and len (TextoComprobar) = 0 Then MsgBox "NO SE HA PODIDO EXTRAER LA PAGINA CON LA QUE COMPARAR EN LA PROXIMA EXTRACCION" WScript.Quit(0) End If If iplay = 1 and TextoComprobar = "[EXTRACT]" Then MsgBox "NO SE HA PODIDO EXTRAER LA PAGINA CON LA QUE COMPARAR EN LA PROXIMA EXTRACCION" WScript.Quit(0) End If If iplay < 0 or buscatext01 <> 0 or buscatext02 <> 0 or buscatext03 <> 0 Then If buscatext01 <> 0 Then errorweb = errortext01 End If If buscatext02 <> 0 Then errorweb = errortext02 End If If buscatext03 <> 0 Then errorweb = "HTTP 404 No se encontró la página" End If MsgBox "HA OCURRIDO EL SIGUIENTE ERROR:" + vbCrLf + errormacro + vbCrLf + errorweb WScript.Quit(0) End If iret = iim1.iimExit 'MOSTRAR EXTRACCION INICIAL EN PANTALLA '====================================== MsgBox "EXTRACCION INICIAL:" + vbCrLf + TextoComprobar 'GUARDAR LA EXTRACCION COMPLETA A UN ARCHIVO HTML PARA COMPROBAR UNA CORRECTA EXTRACCIÓN INICIAL '=============================================================================================== Dim objFileSystem, objOutputFile Dim strOutputFile Const OPEN_FILE_FOR_APPENDING = 8 strOutputFile = "./web-extraida.html" Set objFileSystem = CreateObject("Scripting.fileSystemObject") Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE) objOutputFile.WriteLine(TextoComprobar) objOutputFile.Close Set objFileSystem = Nothing 'COMIENZO DEL BUCLE Y COMPROBACION '================================= TextoExtraido = TextoComprobar Do While TextoExtraido = TextoComprobar Randomize Intervalo = (Int((max-min+1)*Rnd+min))*1000 iret = iim1.iimInit() iplay = iim1.iimPlay("extractor") TextoExtraido buscatext01 = buscatext02 = buscatext03 = = iim1.iimGetLastExtract() InStr(1, TextoExtraido, errortext01, vbTextCompare) InStr(1, TextoExtraido, errortext02, vbTextCompare) InStr(1, TextoExtraido, errortext03, vbTextCompare) If iplay < 0 or buscatext01 <> 0 or buscatext02 <> 0 or buscatext03 <> 0 Then WScript.sleep Timeout*1000 iplay = iim1.iimPlay("extractor") TextoExtraido = iim1.iimGetLastExtract() errormacro = iim1.iimGetLastError() buscatext01 = InStr(1, TextoExtraido, errortext01, vbTextCompare) buscatext02 = InStr(1, TextoExtraido, errortext02, vbTextCompare) buscatext03 = InStr(1, TextoExtraido, errortext03, vbTextCompare) If iplay < 0 or buscatext01 <> 0 or buscatext02 <> 0 or buscatext03 <> 0 Then If buscatext01 <> 0 Then errorweb = errortext01 End If If buscatext02 <> 0 Then errorweb = errortext02 End If If buscatext03 <> 0 Then errorweb = "HTTP 404 No se encontró la página" End If iret = iim2.iimInit() iplay = iim2.iimPlay("paginaalarma") MsgBox "HA OCURRIDO EL SIGUIENTE ERROR:" + WScript.Quit(0) End If End If If TextoExtraido = TextoComprobar Then WScript.sleep Intervalo iret = iim1.iimExit End If Loop 'AL SALIR DEL BUCLE LA ALARMA SALTA '================================== iret = iim2.iimInit() iplay = iim2.iimPlay("paginaalarma") WScript.Quit(0) vbCrLf + errormacro + vbCrLf + errorweb