Ich brauche die Liste der Kampagnen/Vertrieb dieser privaten Verkaufsladen abzurufen: www.showroomprive.comLocken PHP Stellen Sie eine gesicherte Login
ich mit diesen Anmeldeinformationen zuerst anmelden müssen: Anmeldung: stackoverflow37 @ gmail. com Passwort: stackoverflow37
Hier ist mein Code:
<?
//First query is to retrieve __VIEWSTATE , __VIEWSTATEGENERATOR , ... which are necessary for login post
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.showroomprive.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,CURL_SSLVERSION_TLSv1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36");
curl_setopt($ch, CURLOPT_REFERER, 'https://www.amazon.fr/');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
$page = curl_exec($ch);
//Retrieving __VIEWSTATE , __VIEWSTATEGENERATOR , ... out of the html
$page = preg_replace("/\r|\n/", "", $page);
preg_match_all('/.+?__VIEWSTATE" value="(.+?)".+?__VIEWSTATEGENERATOR" value="(.+?)".+?__EVENTVALIDATION" value="(.+?)"/', $page, $result);
$__VIEWSTATE = $result[1][0];
$__VIEWSTATEGENERATOR = $result[2][0];
$__EVENTVALIDATION = $result[3][0];
//preparing the login post query
$header=array(
'Connection: keep-alive',
'Content-Length: 4932',
'Cache-Control: max-age=0',
'Origin: https://www.showroomprive.com',
'Upgrade-Insecure-Requests: 1',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
'Content-Type: application/x-www-form-urlencoded',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Referer: https://www.showroomprive.com/Default.aspx?from=deconnect&p=accueil.aspx',
'Accept-Encoding: gzip, deflate, br',
'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,de;q=0.2,it;q=0.2,ru;q=0.2',
);
$post_fields = array(
'__EVENTTARGET' => "Login$LienLogin",
'__EVENTARGUMENT' => "",
'Login$tbLogin' => "[email protected]",
'Registration$tb_prenom'=> "",
'Registration$tb_nom'=> "",
'Registration$tb_email'=> "",
'Registration$tb_password'=> "",
'Registration$tb_parrain'=> "",
'Login$tbPass' => "stackoverflow37",
'BottomSEO$DDLCountry' => "FR",
'__VIEWSTATE' => $__VIEWSTATE,
'__VIEWSTATEGENERATOR' => $__VIEWSTATEGENERATOR,
'__EVENTVALIDATION' => $__EVENTVALIDATION
);
$fields_string ="";
foreach($post_fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
sleep(2);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.showroomprive.com/Default.aspx?from=deconnect&p=accueil.aspx");
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: __gads=ID=3d4d19bc3863cdac:T=1483799974:S=ALNI_MbJn82hX9AxlSFu5-BXXP9YZVSXkg; _tlp=1156:6742245; srpFp=47; LiwioReferrer=http%3A//www.showroomprive.com/Accueil.aspx%3Ffbc%3D1; abt=1; _gat=1; _gat_analyticsTracker=1; _tli=477999116374116208; _tlc=:1484412282:www.showroomprive.com%2FDefault.aspx%3Fmes%3D%26direction%3D%252faccueil.aspx:showroomprive.com; _gat_audienceTracker=1; cdx_ses_1_11544=2637477935&1599dddfdd7&1599dddfdd7&; SRP=; SRPCRM=; SRPInscription=%3fmes%3d%26direction%3d%252faccueil.aspx; ABTastySession=LiwioHashMRASN%3Anull%5E%7C%5ELiwioUTMC%3A1%5E%7C%5ELiwioReferrerSent%3A1; ABTasty=LPT159050%3A-2.1483800004%5E%7C%5EActionTrackingEvents%3AClic%2520Ajouter%2520au%2520panier%2CAjout%2520Panier%2CAJOUT%2520PANIER%2CClic%2520sur%2520Ajout%2520Panier%5E%7C%5ELPT159868%3A221109.1483800257%5E%7C%5ELPT154065%3A-2.1483800004%5E%7C%5ELPT161532%3A225711.1483800004%5E%7C%5ELPT149830%3A-2.1483799968%5E%7C%5EABTastyUTMB%3A1%5E%7C%5ELiwioTracking%3A17010715390683616*159868.221109*161532.225711%5E%7C%5EsegmentationTracking%3A17010715390683616%5E%7C%5ELiwioUTMA%3A0.5.1483799946162.1484409283679.1484412281027.3*161532.5*159868.5; _ga=GA1.2.369897606.1483799946; _tlv=5.1483799947.1484410366.1484412435.54.6.3; _tls=*.763002,763004..477999116374116208; _lm_id=45I54MGV5FWBNW55; tCdebugLib=1"));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,CURL_SSLVERSION_TLSv1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36");
curl_setopt($ch, CURLOPT_REFERER, 'https://www.showroomprive.com/');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
$page = curl_exec($ch);
echo $page;
?>
das Problem ist, dass Kopf- und postfields trotz, die genau gleich aussehen wie meine Chrome-Browser, ich habe immer noch die Website mir als ein Erfassungs locken Abfrage.
Gibt es irgendetwas, das ich hinzufügen muss, damit die curl-Abfrage nur als Browser betrachtet wird?
Funktioniert perfekt. Vielen Dank – justberare