Re: Preguntita medio loca

From: Date: Sun, 13 Aug 2000 11:38:22 +0000
Subject: Re: Preguntita medio loca
Groups: php.general.es 
Request: Send a blank email to general-es+get-968@lists.php.net to get a copy of this message
La estructura de esa pagina es bien simple, con unas expresiones regulares fue bien sencillo el escribir un script como: <?php // For Luis Tena // JMC, a quick hack $table_re = "</H3>(<TABLE.*/TABLE>)<H3>"; $data = implode("", file("http://207.76.75.106/cgi-bin/mgen.cgi?file=pilots.mhtml")); // extract the table ereg($table_re, $data, &$extracted); // do some cleanup on the text, and pick only table cells $contents = strip_tags($extracted[1],"<td>"); $contents = ereg_replace("[[:blank:]]{2,}","",$contents); // add some end-of-lines to make it into an array $contents = str_replace("</TD>","</TD>\n",$contents); $contents = explode("\n",$contents); // process each set of 5 table cells. $td_re = "<TD>([^<]+)</TD>"; for ($i=0; $i<count($contents); $i+=5) { ereg($td_re, $contents[$i], &$reg); $call = $reg[1]; unset($reg); ereg($td_re, $contents[$i+1], &$reg); $name = $reg[1]; unset($reg); ereg($td_re, $contents[$i+2], &$reg); $depart = $reg[1]; unset($reg); ereg($td_re, $contents[$i+3], &$reg); $dest = $reg[1]; unset($reg); ereg($td_re, $contents[$i+4], &$reg); $server = $reg[1]; unset($reg); echo "$call\t$name\t$depart\t$dest\t$server\n"; } ?> Modifica el programa para tus propositos, en particular si el patron del texto cambia, para lo cual deberas modificar las expresiones regulares. Saludos. --- Jesus M. Castagnetto P.S. Usa text simple para la proxima, no HTML como se muestra abajo. Quoting Luis Tena <tena@avantel.net>: > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > <HTML><HEAD> > <META http-equiv=Content-Type content="text/html; > charset=iso-8859-1"> > <META content="MSHTML 5.50.4030.2400" name=GENERATOR> > <STYLE></STYLE> > </HEAD> > <BODY bgColor=#ffffff> > <DIV><FONT face=Arial size=2>Saludos, agradeceria su > ayuda.</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV> > <DIV><FONT face=Arial size=2>Tengo un dilema.. quiero hacer una > consulta a una > pagina externa que se genera con un cgi... <A > href="http://207.76.75.106/cgi-bin/mgen.cgi?file=pilots.mhtml">http:/> /207.76.75.106/cgi-bin/mgen.cgi?file=pilots.mhtml</A>&nbsp;y > desplegarla en mi pagina dentro del formato que estoy usando, ahi no > tengo > problema si quisiera mostrar la pagina tal cual aparece en el sitio de > origen > con un fopen.. pero lo que quiero es depurar ese contenido que arroja la > pagina > y mostrar solo los datos que yo quiero que vienen dentro del mhtml que > arroja en > mi propio formato de mi pagina como le puedo hacer?</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV> > <DIV><FONT face=Arial size=2>actualmente estoy desplegando la pagina > tal cual la > envia el servidor externo.</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV> > <DIV><FONT face=Arial size=2>de aqui proviene la pagina que quiero > depurar <A > href="http://207.76.75.106/cgi-bin/mgen.cgi?file=pilots.mhtml">http:/> /207.76.75.106/cgi-bin/mgen.cgi?file=pilots.mhtml</A></FONT></DIV> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV> > <DIV><FONT face=Arial size=2>esta es mi pagina <A > href="http://216.147.120.219/index.php3?ir=satnet.php3">http://216.14> 7.120.219/index.php3?ir=satnet.php3</A></FONT></DIV> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV> > <DIV><FONT face=Arial size=2>Gracias mil de antemano</FONT></DIV> > <DIV><FONT face=Arial size=2>Luis Tena</FONT></DIV> > <DIV><FONT face=Arial size=2>Mexico > DF</FONT></DIV></BODY></HTML> > ------------------------------------------------- Created by Zkey.com - http://www.zkey.com Awarded PCMagazine's Editors' Choice

« previous php.general.es (#968) next »