Foros del Web » Programando para Internet » PHP »

ayuda con bot

Estas en el tema de ayuda con bot en el foro de PHP en Foros del Web. Hola kiero hacer un bot que compruebe si existen una serie de enlaces en megaupload...tengo el siguiente código Código PHP: <html> <?php include ( 'config.php' ) ; ...
  #1 (permalink)  
Antiguo 20/12/2008, 12:47
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Exclamación ayuda con bot

Hola kiero hacer un bot que compruebe si existen una serie de enlaces en megaupload...tengo el siguiente código


Código PHP:
<html>
<?php
include ('config.php') ;
$cogenlaces mysql_query("select * from torrents_descargas where id=5900");
$enlaces mysql_fetch_array($cogenlaces);
$archivo file("$enlaces[eunico]");
foreach(
$archivo as $linea) {
    if(
stristr($linea'Invalid')) echo 'Encontrado';

}

?>
<html>
Me gustaria modificarlo para que me comprobara los enlaces que se guardan en 10 campos distintos de todos los registros de la tabla y si alguno de los 10 falla pues en un campo llamado status por ejemplo inserte 0 o 1 dependiendo de si esta disponible o no,,, la tabla lleva un campo incremental llamado id por si es de ayuda

saludos y muchas gracias esto un poco liado con el script
  #2 (permalink)  
Antiguo 20/12/2008, 16:45
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Es la misma logica, haces la consulta, creas un bucle y dentro del bucle llamas a file_get_contents() y revisas si existe la cadena Invalid. Si existe, haces, dentro del mismo bucle anterior, un query para actualizar el campo usando la clausula WHERE.
  #3 (permalink)  
Antiguo 21/12/2008, 12:10
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

gracias, si pero es que no se exactamente como es aver si me escrives un poco del codigo que vea el ejemplo

gracias
  #4 (permalink)  
Antiguo 21/12/2008, 12:43
 
Fecha de Ingreso: febrero-2007
Mensajes: 43
Antigüedad: 17 años, 2 meses
Puntos: 0
Respuesta: ayuda con bot

en vez de :
Cita:
foreach($archivo as $linea) {
if(stristr($linea, 'Invalid')) echo 'Encontrado';

}
foreach($archivo as $indice => $linea) {
if(stristr($linea, 'Invalid')){
aki metemos la modificacion de la tabla..
INSERT INTO tabla VALUES($indice , status)
}
}

no se prueba..
  #5 (permalink)  
Antiguo 21/12/2008, 14:32
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Código PHP:
$query mysql_query("SELECT * FROM tuTabla");
while(
$row mysql_fetch_assoc($query)) {
  
$file file_get_contents($row['campoUrl']);
  if(
stristr($file'Invalid')) mysql_query("UPDATE tabla(columna) VALUES('0') WHERE id = '".$row['id']."'");
  else 
mysql_query("UPDATE tabla(columna) VALUES('1') WHERE id = '".$row['id']."'");

  #6 (permalink)  
Antiguo 21/12/2008, 14:57
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

gracias, pero he dejado el codigo así

Código PHP:
<?php
include ('config.php') ;
$query mysql_query("SELECT * FROM torrents_descargas");
while(
$row mysql_fetch_assoc($query)) {
  
$file file_get_contents($row['eunico']);
  if(
stristr($file'Invalid')) mysql_query("UPDATE torrents_descargas(status) VALUES('0') WHERE id = '".$row['id']."'");
  else 
mysql_query("UPDATE torrents_descargas(status) VALUES('1') WHERE id = '".$row['id']."'");
}

?>
y cuadno lo ejecuto m lanza al rato este error

Código PHP:
Fatal errorMaximum execution time of 30 seconds exceeded in C:AppServwwwestrenosbot.php on line 6 
Y he probado a en la consulta del select con limit pero aora no tira el error anterios pero no inserta nada en status

saludos y muchas gracias por todo
  #7 (permalink)  
Antiguo 21/12/2008, 15:03
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Cita:
Fatal error: Maximum execution time of 30 seconds exceeded in C:AppServwwwestrenosbot.php on line 6
El script esta excediendo el maximo tiempo de ejecucion de tu php.ini
Talvez podrias usar set_time_limit() dentro del bucle while para ir agregando tiempo y el script no exceda el limite.

Sino inserta nada en el status es porque estas haciendo algo mal en tu consulta, agregale un:
or die(mysql_error());

http://www.php.net/manual/en/functio...time-limit.php
  #8 (permalink)  
Antiguo 21/12/2008, 15:48
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

lo hice y me lanza este error


Código PHP:
You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near '(status) VALUES('1') WHERE id = '5701'' at line 1 
gracias
  #9 (permalink)  
Antiguo 21/12/2008, 15:50
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Muestrame la consulta que ejecutas.
  #10 (permalink)  
Antiguo 21/12/2008, 15:55
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

<html>
<?php
include ('config.php') ;
$query = mysql_query("SELECT * FROM torrents_descargas");
while($row = mysql_fetch_assoc($query)) {
$file = file_get_contents($row['eunico']);
if(stristr($file, 'Invalid')) mysql_query("UPDATE torrents_descargas(status) VALUES('0') WHERE id = '".$row['id']."'");
else mysql_query("UPDATE torrents_descargas(status) VALUES('1') WHERE id = '".$row['id']."'")or die(mysql_error($conectar))or set_time_limit();;


}

?>
<html>
  #11 (permalink)  
Antiguo 21/12/2008, 15:58
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Ah disculpa, el error fue mio.
Me confundi con la sintaxis del UPDATE. xD

Esa es la de INSERT.
Update es:
UPDATE tabla SET campo=valor WHERE id=0;
  #12 (permalink)  
Antiguo 21/12/2008, 16:09
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

estoy echo un lio ya jejeje

aora tnego codigo asi

Código PHP:
<html>
<?php
include ('config.php') ;
$query mysql_query("SELECT * FROM torrents_descargas");
while(
$row mysql_fetch_assoc($query)) {
  
$file file_get_contents($row['eunico']);
  if(
stristr($file'Invalid')) mysql_query("UPDATE torrents_descargas status = 0 WHERE id = ".$row['id']." ");
  else 
mysql_query("UPDATE torrents_descargas status = 1 WHERE id = ".$row['id']."")or die(mysql_error($conectar))or set_time_limit();;
  

}

?>
yme da este error

Código PHP:
You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near '= 1 WHERE id = 5701' at line 1 
  #13 (permalink)  
Antiguo 21/12/2008, 16:25
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con bot

Te falto el SET.
UPDATE tabla SET campo=valor
  #14 (permalink)  
Antiguo 22/12/2008, 04:42
 
Fecha de Ingreso: octubre-2008
Mensajes: 46
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con bot

ok, gracias ahora si funciona, pero ahora cmo podria hacer para que lo haga cuando encuentre invalid o removed , una de las dos palabras no las dos

gracias, he probado con or pero no
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 15:11.