PHP卷曲超链接问题

PHP卷曲超链接问题,php,curl,Php,Curl,我已经编写了一些简单的代码,可以检索给定的网页,在本例中是Google <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.google.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> 虽然它可以工作,但我注意到当我点击一些超链接时,例如“隐私”超链接,我会被重定向到明显不存

我已经编写了一些简单的代码,可以检索给定的网页,在本例中是Google

<?php



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);

?>


虽然它可以工作,但我注意到当我点击一些超链接时,例如“隐私”超链接,我会被重定向到明显不存在的超链接。为什么会发生这种情况?是否可以重定向到正确的链接?

原始html的链接是/intl/en/policies/privacy/没有域名。因此,您的浏览器正在使用所连接的服务器填写域名。那么,如何获取具有正确域名的链接?感谢您的帮助,不幸的是,此代码仅返回curl信息。您是否找到更好的解决方案?当你们得到解决方案时,请分享答案。
<?php

function cURL() {

    // Create a new cURL resource
    $curl = curl_init(); 

    if (!$curl) {
        die("Couldn't initialize a cURL handle"); 
    }

    // Set the file URL to fetch through cURL
    curl_setopt($curl, CURLOPT_URL, "http://ctrlq.org/");

    // Set a different user agent string (Googlebot)
    curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)'); 

    // Follow redirects, if any
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 

    // Fail the cURL request if response code = 400 (like 404 errors) 
    curl_setopt($curl, CURLOPT_FAILONERROR, true); 

    // Return the actual result of the curl result instead of success code
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    // Wait for 10 seconds to connect, set 0 to wait indefinitely
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);

    // Execute the cURL request for a maximum of 50 seconds
    curl_setopt($curl, CURLOPT_TIMEOUT, 50);

    // Do not check the SSL certificates
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 

    // Fetch the URL and save the content in $html variable
    $html = curl_exec($curl); 

    // Check if any error has occurred 
    if (curl_errno($curl)) 
    {
        echo 'cURL error: ' . curl_error($curl); 
    } 
    else 
    { 
        // cURL executed successfully
        print_r(curl_getinfo($curl)); 
    }

    // close cURL resource to free up system resources
    curl_close($curl);
}