[ create a new paste ] login | about

Link: http://codepad.org/YE6fyzCA    [ raw code | output | fork | 3 comments ]

PHP, pasted on May 7:
<?php
if (!function_exists('curl_version')) {
    exit("Enable cURL in PHP");
}

$url = "https://www.google.com/";

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_POSTFIELDS => "",
    CURLOPT_HTTPHEADER => array(
        "Accept: */*",
        "Cache-Control: no-cache",
        "Connection: keep-alive",
        "Host: " . url($url),
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36",
        "accept-encoding: gzip, deflate",
        "cache-control: no-cache",
    ),
));

function url($url)
{
    $result = parse_url($url);
    return $result['host'];
}
$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo "<textarea>" . $response . "</textarea>";

}


Output:
1
Enable cURL in PHP


Create a new paste based on this one


Comments:
posted by web03 on Jul 22
dssff fffs
reply
posted by qazwsxedc on Jan 2
sddfdg
reply
posted by qazwsxedc on Jan 2
grthrt
reply