Veröffentlicht 23. November 200519 j Hi, ich habe folgenden Code der mir den Source einer Internetseite anzeigt (mit Proxy). Problem ist das bei manchen php Seiten z.B. http://www.zend.com/store/free_download.php oder http://www.onlinefussballmanager.de/menu.php funktioniert es einfach nicht -> $socket ist false Die errno ist 0 und errstr ist leer. In der PHP Manual steht: ... Wenn die erhaltene errno 0 ist und die Funktion FALSE/falsch zurück gibt, ist dies ein Hinweis, dass der Fehler vor dem >connect()-Aufruf geschah. Das ist ein Problem, dass häufig mit der Initialisierung des Sockets zusammen hängt. ... Dann liegt es irgendwie an der Url ? Es geht ja sonst problemlos ... Für alle die mir helfen wollen, hier der komplette Code: <html> <head> <title>parseHTML</title> <style type="text/css"> body { color: #000000; font-family: Verdana; font-size: 10px; margin: 0px; } </style> </head> <body> <table width="100%" height="100%" border="0"> <?php $strUrl = ""; if(isset($_POST['bSubmit']) && isset($_POST['strUrl'])) { $strUrl = $_POST['strUrl']; $strProxyName = "meinproxy"; $strProxyPort = 8080; $strContent = ""; $socket = fsockopen($strProxyName,$strProxyPort,$iError,$strError,10); if(!$socket) { $strContent = ""; } else { fputs($socket,"GET $strUrl HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\nHost: $strProxyName\r\n\r\n"); while(!feof($socket)) { $strContent .= fread($socket,4096); } fclose($socket); $strContent = substr($strContent,strpos($strContent,"\r\n\r\n") + 4); } if($strContent == "") { echo "<tr>\n<td height=\"50\">Error (" . $iError . "): " . $strError . "</td>\n</tr>\n"; echo "<tr>\n<td> </td>\n</tr>\n"; } else { // Code in Datei schreiben ... $strFileName = "pages/" . date("Y-m-d_H-i-s") . "_" . preg_replace("/[:.\/\\\\?=_&]/i","",$strUrl) . ".html"; $fh = fopen($strFileName,"w"); fputs($fh,$strContent); fclose($fh); echo "<tr>\n<td height=\"50\">File parsed to " . $strFileName . "</td>\n</tr>\n"; echo "<tr>\n<td><iframe src=\"" . $strFileName . "\" name=\"parseframe\" width=\"100%\" height=\"100%\"></iframe></td>\n</tr>\n"; } } ?> <tr> <td valign="top" height="50"> <br> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <input type="text" name="strUrl" value="<?php echo $strUrl ?>" size="100"> <input type="submit" name="bSubmit" value="parse"> </form> </td> </tr> </table> </body> </html>[/PHP] Danke! Gruß Scratch
23. November 200519 j Autor Für alle die mal was ähnliches vor haben ... http://snoopy.sourceforge.net Ausschnitt aus der Doku ... DESCRIPTION: What is Snoopy? Snoopy is a PHP class that simulates a web browser. It automates the task of retrieving web page content and posting forms, for example. Some of Snoopy's features: * easily fetch the contents of a web page * easily fetch the text from a web page (strip html tags) * easily fetch the the links from a web page * supports proxy hosts * supports basic user/pass authentication * supports setting user_agent, referer, cookies and header content * supports browser redirects, and controlled depth of redirects * expands fetched links to fully qualified URLs (default) * easily submit form data and retrieve the results * supports following html frames (added v0.92) * supports passing cookies on redirects (added v0.92)
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.