0

I'm trying to parse some data from cite. One of the necessary parameters is cookie value, more precisely, the next values of it:

Cookie: ipp_uid2=efliElW4ac8ZN1ij/Z/HcwOZTR8GjhSAoyZq96A==; 
ipp_uid1=1551805782684; ipp_key=v1551805782684/v3394bd6affd4485fec9704163aeca6afa04ab3/GUF3kfsYsBwa3cRGpzpV2g==;

I got this from incognito in google chrome "by hand". It changes every hour and I want to get it automatically. Without these values curl query doesn't work.

How can i get theese values by using curl or maybe other ways automatically?

The query code:

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $task);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Cookie: ipp_uid2=efliElW4ac8ZN1ij/Z/HcwOZTR8GjhSAoyZq96A==; ipp_uid1=1551805782684; ipp_key=v1551805782684/v3394bd6affd4485fec9704163aeca6afa04ab3/GUF3kfsYsBwa3cRGpzpV2g==;",
    "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$server_output = curl_exec($ch);
echo $server_output;
curl_close ($ch);   
  • Get the cookies from where? Do you have an initial curl request (e.g. login) that yields the Set-Cookie headers? Or do you want to read them out from [Chromes´ cookies.txt](https://stackoverflow.com/questions/31021764/where-does-chrome-store-cookies)? – mario Mar 05 '19 at 18:20
  • PD of [PHP Curl And Cookies](//stackoverflow.com/q/12885538) (retaining session cookies is a built-in feature already) – mario Mar 05 '19 at 18:21
  • I've tried to get cookie by the next way: `curl_setopt($ch, CURLOPT_COOKIEJAR, realpath('cookie_cdek.txt')); curl_setopt($ch, CURLOPT_COOKIEFILE, realpath('cookie_cdek.txt'));` There is nothing in cookie.txt. Also I recieved headers from curl by `curl_setopt($ch, CURLOPT_HEADER, 1);`. In this case cookie looks like `rerf=AAAAAFx/1vVEdjoEAwyjAg==; expires=Fri, 05-Apr-19 14:19:33 GMT; path=/`. There is no any `ipp_uid1,ipp_uid2, ipp_key` in it. So, the question is, how can I get the cookie with theese parameters. (They always appear when I consider the request in chrome). – Никита Харитонов Mar 06 '19 at 14:17
  • There is no any login on cite. I only enter the parameters and push the button to recieve answer. When I push the button the POST request is sended. I try to simulate this POST request. And it works only when I put the cookies from incognito in Google Chrome and User-Agent as the CURLOPT_HTTPHEADER. – Никита Харитонов Mar 06 '19 at 14:25

0 Answers0