Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

fsockopen und errno=0

Empfohlene Antworten

Veröffentlicht

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

  • 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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.