Last active
November 17, 2017 00:44
-
-
Save spacebit-official/831a7068f46bba1b69e94800581381c7 to your computer and use it in GitHub Desktop.
curl
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
| <? | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $url); //http/https адрес | |
| curl_setopt($ch, CURLOPT_NOBODY, true); //без тела | |
| curl_setopt($ch, CURLOPT_HEADER, true); //смотреть заголовки | |
| curl_setopt($ch, CURLOPT_COOKIE, 'cookie=777'); //отправляем куки | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); | |
| curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //следование за перенаправлением | |
| curl_setopt($ch, CURLOPT_FILE, $fp); // запись в файл *третий аргумент это дескриптор файла | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //запись в переменную | |
| curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36"); | |
| $res = curl_exec($ch); //выполнение запроса | |
| curl_close($ch); //завершение сеанса | |
| function get_content($url) { | |
| $ch = curl_init($url); | |
| curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $res = curl_exec($ch); | |
| curl_close($ch); | |
| return $res; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment