Last active
January 19, 2016 10:28
-
-
Save VictorFursa/4bec6f8c97b940c85383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $username = 'Zir4onah'; | |
| $password = '540919zir'; | |
| $login_url = 'http://www.kinopoisk.ru/login'; | |
| $agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; | |
| $ch = curl_init(); //инициализация библиотеки | |
| //указываем адрес страницы | |
| curl_setopt($ch, CURLOPT_URL,$login_url); | |
| //указываем заголовок User-Agent | |
| curl_setopt($ch, CURLOPT_USERAGENT, $agent); | |
| //указываем, что полученная страница должна быть сохранена в переменную | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| //указываем, что cURL должен переходить по редиректам | |
| curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
| $refer = 'http://www.kinopoisk.ru/login/'; | |
| $formData = array( | |
| "shop_user" => array( | |
| "login" => $username, | |
| "pass" => $password, | |
| "mem" => "on" | |
| ), | |
| "auth"=>"войти на сайт"); | |
| //referer - адрес страницы с которой вы пришли, | |
| //т.е. нужно указать адрес страницы на которой находится форма | |
| curl_setopt($ch, CURLOPT_REFERER, $refer); | |
| //указываем, что мы отправляем данные методом post | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| //добавляем строку с post данными | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formData)); | |
| //создаем файл для cookies | |
| $cookiefile = tempnam('/var/www/alcoholic.com/', 'cookies.txt'); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); | |
| curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); | |
| //выполняем запрос | |
| echo $page = curl_exec($ch); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment