Einzelnen Beitrag anzeigen
  #7  
Alt 22.03.2017, 00:35:42
AlexD AlexD ist offline
Junior Member
 
Registriert seit: Jun 2003
Beiträge: 186
AW: Daten von anderer Seite auslesen

Sorry, hatte die Tage wenig Zeit.

Wie ich festgestellt habe, funktioniert wohl schon der Login nicht wirklich da mir die "Login-Fehler Seite" ausgegeben wird.

Für den Login muss nur die lokale Adresse eingegeben werden damit die Login-Felder erscheinen. (z.B. http://sz-haus.ma-home.local)

im Quelltext des Formulars steht folgendes - steh da irgendwie auf dem Schlauch. :-/
HTML-Code:
<form name="login" method="post" action="index">
 <br>
  <table align="center" bgcolor="#98c2f0" cellpadding="5" cellspacing="5"><tbody>
   <tr>
    <td class="testo">Benutzername:</td>
    <td><input name="user" maxlength="20" style="width: 100px;" type="text"></td>
   </tr>
   <tr>
    <td class="testo">Passwort:</td>
    <td><input name="password" maxlength="20" style="width: 100px;" type="password"></td>
   </tr>
    <input name="action" value="login" type="hidden">
   <tr>
    <td colspan="2" align="center"><input name="login" title="Login" value="Login" class="invia" type="submit"></td>
   </tr>
  </tbody></table>
</form>

Mit PHP bzw. cUrl versuche ich mich so einzuloggen und dann die Datei zu speichern.
Username und Password sind korrekt!

PHP-Code:
$username 'xxxxx';
$password 'xxxxx';
$loginUrl 'http://sz-haus.ma-home.loacl';

//init curl
$ch curl_init();

//Set the URL to work with
curl_setopt($chCURLOPT_URL$loginUrl);

// ENABLE HTTP POST
curl_setopt($chCURLOPT_POST1);

//Set the post parameters
curl_setopt($chCURLOPT_POSTFIELDS'user='.$username.'&password='.$password.'&action=login');

//Handle cookies for the login
curl_setopt($chCURLOPT_COOKIEJAR'cookie.txt');

//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($chCURLOPT_RETURNTRANSFER1);

//execute the request (the login)
$store curl_exec($ch);

//the login is now done and you can continue to get the
//protected content.

//set the URL to the protected file
curl_setopt($chCURLOPT_URL'http://sz-haus.ma-home.local/storage?action=download');

//execute the request
$content curl_exec($ch);

curl_close($ch);

//save the data to disk
file_put_contents('./wr1.csv'$content); 
Mit Zitat antworten