A
A
Andrei12314122019-11-07 18:42:00
PHP
Andrei1231412, 2019-11-07 18:42:00

The parser does not work with a certain wanderer, why?

Why is parsing not working from this page?? - https://soccer365.ru/games/921770/
From the page - https://soccer365.ru/ everything is ok
Not working

$url = 'https://soccer365.ru/games/921770/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "GOOGLE");  // Обманочка
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
echo $output;

Works
$url = 'https://soccer365.ru/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "GOOGLE");  // Обманочка
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
echo $output;

How can I get data from this page - https://soccer365.ru/games/921770/ ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nujabes37, 2019-11-07
@Nujabes37

Nah, that's how it works)

$context = stream_context_create(
    [
        'http' => [
            'method'        => 'GET',
            'header'        => "path: /games/921770/\r\n" .
                               "User-agent: Mozilla/5.0 (Linux; Android 4.4.4; HM NOTE 1LTEW Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 MicroMessenger/6.0.0.54_r849063.501 NetType/WIFI\r\n",
            'ignore_errors' => true,
        ],
    ]
);

$request = file_get_contents(
    'https://soccer365.ru/games/921770/',
    false,
    $context
);

die(print_r($request));

P
Pavel Chesnokov, 2019-11-07
@cesnokov

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "GOOGLE");  // Обманочка
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);

echo '<pre>';
print_r( curl_getinfo($ch) );
echo '</pre>';

curl_close($ch);
echo $output;

Yes, you just get a 301 code:
Array
(
    [url] => https://soccer365.ru/games/921770/
    [content_type] => text/html; charset=UTF-8
    [http_code] => 301
    [header_size] => 539
    [request_size] => 84
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.255368
    [namelookup_time] => 0.000614
    [connect_time] => 0.02999
    [pretransfer_time] => 0.19802
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0.25531
    [redirect_time] => 0
    [redirect_url] => https://soccer365.ru//soccer365.ru/live/match-etyir-1924-levski-smotret-onlayn/
    [primary_ip] => 51.15.25.134
    [certinfo] => Array
        (
        )
)

Use "redirect_url", etc.

E
Eugene, 2019-11-08
@Nc_Soft

CURLOPT_FOLLOWLOCATION

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question