7

I have a PHP scraper that works perfectly on my local. But when I uploaded it to my VPS (Ubuntu 16.04), it's not able to get data from the website. Instead, it's showing this error message:

"curl: (56) GnuTLS recv error (-54): Error in the pull function"

I updated Openssl, Curl, GnuTLS still no luck. Tried to perform CURL from command line, it showed same error. It should be something to do with CURL /GnuTLS. I saw some people had same error message when using Git and fixed it but that solution isn't working in my case. Is there any way to fix it?

Here is the PHP function I use to get data from website:

function get_html($url)
{
    $agent= 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Mobile Safari/537.36';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'Accept-Language: q=0.9,en-US;q=0.8,en;q=0.7',
        'Connection: keep-alive'
 ));


    curl_setopt($ch, CURLOPT_URL,$url);
    $pageContent = curl_exec($ch);

    curl_close($ch);

    return $pageContent;
}

Thanks in advance.

Fatih Köse
  • 121
  • 1
  • 6

0 Answers0