Guys, save, 3 days I deal with this captcha, cookies, sessions, and in response there is always one thing - wrong captcha.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> Парсер ;) </title> </head> <body> <?php $url = 'https://my.maerskline.com/tracking/search'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_REFERER, $url); $content = curl_exec($ch); preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $content, $matches); $cookies = array(); foreach($matches[1] as $item) { parse_str($item, $cookie); $cookies = array_merge($cookies, $cookie); } foreach($cookies as $key => $value) { @$cookiee .= $key.'='.$value.';'; } $cookiee = substr($cookiee,-1); $content = str_replace('<img class="pull-left captcha-img" src="', '<img class="pull-left captcha-img" src="https://my.maerskline.com', $content); $content = str_replace('<form action="', '<form action="https://my.maerskline.com', $content); preg_match('/captcha\?id=[0-9A-Za-z\-]{1,100}/',$content,$matches); $id = substr($matches[0],11); preg_match('/captcha\?id=[0-9A-Za-z\-]{1,100}/',$content,$matches); preg_match('/https:\/\/my.maerskline.com\/captchaapp\/captcha\?id=[0-9A-Za-z\-]{1,100}/',$content,$matches); ?> <form action="" method="get"> <input type="hidden" name="randomID" value="<?php echo $id ?>" /> <input type="text" name="searchNumber" placeholder="Номер"/> <img src="<?php echo $matches[0]; ?>"/> <input type="text" name="code" placeholder="Капча"/> <input type="submit" name="send" value="Получить информацию"> </form> <?php if(isset($_GET['send'])) { $url = 'https://my.maerskline.com/tracking/search?randomID='.$id.'&searchNumber='.$_GET['searchNumber'].'&code='.$_GET['code']; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_COOKIE, $cookiee); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $content = curl_exec($ch); curl_close($ch); echo $content; } ?> </body> </html> The most interesting thing is if you take the GET line that generated the locale and insert it here https://my.maerskline.com/tracking/search then it will work! and if you do the same thing with a curl, then a wrong captcha ... I understand that there are problems in the headers, cookies, sessions. But I do not understand how to properly parse and send them, so that it would be exactly the same. Or maybe another problem? Push the thought, please.