Good day. It is necessary to parse several pages with https://www.sravni.ru/ , some time ago the script stopped working (it used to be http : //www.sravni.ru/) but I don’t do anything that I can’t get the page. Tried and denied the verification of certificates and substituted the certificate - the result is in any case "Unknown SSL protocol error in connection to www.sravni.ru:443" One of the options below:

function get_web_page($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FORBID_REUSE, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, false); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"); $content = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch); $header = curl_getinfo($ch); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } 

tried this:

 curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false); 

... and such:

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/www.sravni.ru.crt"); 

Which way to dig?

PS: php 5.4, ssl enabled. In some variant received once - Protocol "https" not supported or disabled in libcurl

  • CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2 are you sure? Generally added a bunch of unnecessary options - ArchDemon
  • Not sure ... I tried it and version 1. Started with a simple version with 3 lines) - Marran ff

1 answer 1

Now, without problems, sparsil:

 $url = 'https://www.sravni.ru/'; if($curl = curl_init()) { curl_setopt($curl,CURLOPT_URL, $url); curl_setopt($curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true); curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,30); curl_setopt($curl,CURLOPT_USERAGENT,'Bot 1.0'); $html = curl_exec($curl); curl_close($curl); } echo $html; 

PHP Version 5.6.27 curl 7.51.0

  • doesn't parse (For a sample of sparsil banks.ru and a couple of https pages including Yandex. All the rules but compare. still returns false. I will try to install php 7, now 5.4.29 and curl 7.36.0 - Marran ff
  • c php7 doesn't plow either - Marran ff
  • Maybe corny in the bath? - Vadim
  • How to check? From the browser page opens, from the script there. What is strange from IE does not open, only from firefox. - Marran ff