PHP卷曲彩票检查页面

PHP卷曲彩票检查页面,php,curl,Php,Curl,我想有一个彩票检查页用php编写。该代码不适用于匈牙利彩票数据库($url2),但适用于其他数据库($url1)。太多的数据是问题所在吗 <?php echo "CURL - function test <br>"; $url1 = "http://www.example.com"; $url2 = "https://bet.szerencsejatek.hu/cmsfiles/otos.html"; function curl_download($Url){ //

我想有一个彩票检查页用php编写。该代码不适用于匈牙利彩票数据库($url2),但适用于其他数据库($url1)。太多的数据是问题所在吗

<?php
echo "CURL - function test <br>";
$url1 = "http://www.example.com";
$url2 = "https://bet.szerencsejatek.hu/cmsfiles/otos.html";

function curl_download($Url){

    // is cURL installed yet?
    if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;
}


echo curl_download($url2);
echo strlen(curl_download($url2));

首先,它取决于错误是什么

我认为你应该把卷曲工作的结果扔掉。差不多

    if (!curl_errno($ch)) {
        switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
            case 200:  # OK
                $return = ['result' => 'ok', 'response_text' => $result];
                break;
        default:
            $return = ['result' => 'unexpected_http_code', 'http_code' => $http_code,
                'response_text' => $result
            ];
        }
    } else {
        $return = ['result' => 'curl_error', 'curl_error' => curl_error($ch)];            
    }
可能是因为您没有配置SSL设置,因为第二个URL以https开头://