D
D
Dzonke2022-02-20 17:40:00
PHP
Dzonke, 2022-02-20 17:40:00

How to parse a closed page in PHP?

Hello everyone, there was a task to parse a closed page (available only after authorization). I use curl + save cookies while the result of the code is always the same regardless of the login / password:
bool(true)
I would be very grateful if you point out my mistakes to me.

<?php header('Content-type: text/html; charset=utf-8');

function get_content($url, $data=[]) 

{

    $ch = curl_init($url); 

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch, CURLOPT_POST, true);

    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

    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

1 answer(s)
R
rPman, 2022-02-20
@Dzonke

If the site is protected from this, then it is necessary to more accurately simulate the behavior of the web client, namely all the headers and perhaps even the sequence of requests before the right one. It is possible that even timings are also taken into account (and I would also mark as dangerous from a host from which at least sometimes atypical requests with the curl user agent arrive and send them to the sandbox with atypical behavior in order to confuse reverse engineering even more)
see the details in the network tab right button on the request - copy curl bash, it will be very convenient and clear everything is laid out on the shelves with an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question