D
D
Dzonke2022-02-20 19:44:58
PHP
Dzonke, 2022-02-20 19:44:58

403 Forbidden on curl parsing?

What can cause a 403 error to appear when parsing a closed page?

header('Content-type: text/html; charset=utf-8');
function get_content($url, $data=[]) 
{
    $ch = curl_init($url); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'X-Requested-With: XMLHttpRequest',
        'Accept: application/xml, text/xml, */*; q=0.01',
        'Faces-Request: partial/ajax',
        'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
        'Host: site.ru',
        'Origin: https://www.flightclub.com',
        'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
    ]);       
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ .'/cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ .'/cookie.txt');
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

$url_auth = "https://www.flightclub.com/customer/account/login?redirectTo=MyAccount";
$url = "https://www.flightclub.com/my-account";

$auth_data = [
    'email' => "email',
    'password' => 'password',
];

$data = get_content($url_auth, $auth_data);
var_dump($data);
$data = get_content($url);

var_dump($data);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question