V
V
Vlad Osadchyi2018-09-17 10:13:56
PHP
Vlad Osadchyi, 2018-09-17 10:13:56

403 error while parsing?

I can't get data from this site sofifa.com.
Tried through cURL and through file_get_contents (), it gives an error 403.
What are your guesses, why does it not work?

The code
function parse ($url)
  {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    $result = curl_exec($curl);
    return $result;
  }
  echo parse('https://sofifa.com/');

echo file_get_contents('https://sofifa.com/');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-09-17
@VladOsadchyi

Good morning.

function parse ($url)
  {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36");
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    $result = curl_exec($curl);
    return $result;
  }
  echo parse('https://sofifa.com/');

The output table
5b9f56607f3e8930770745.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question