通过PHP或JAVASCRIPT获取https网站html代码

通过PHP或JAVASCRIPT获取https网站html代码,javascript,php,Javascript,Php,我试过file\u get\u content和curl,但这两种方法在网站上都不起作用。我在以前的项目中都使用过 网站: 任何人都有一个有效的解决方案。已查找和测试数小时: 卷曲似乎也不起作用 HTTP/1.1 200 OK内容长度:5395 Pragma:无缓存控制:无缓存内容类型:text/html 重定向到我自己的主域名 我使用了以下代码: <?php function geturl($url){ (function_exists('curl_init')

我试过file\u get\u content和curl,但这两种方法在网站上都不起作用。我在以前的项目中都使用过

网站:

任何人都有一个有效的解决方案。已查找和测试数小时:

卷曲似乎也不起作用

HTTP/1.1 200 OK内容长度:5395 Pragma:无缓存控制:无缓存内容类型:text/html

重定向到我自己的主域名 我使用了以下代码:

    <?php
    function geturl($url){

    (function_exists('curl_init')) ? '' : die('cURL Must be installed for geturl function to work. Ask your host to enable it or uncomment extension=php_curl.dll in php.ini');

$cookie = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; CrawlBot/1.0.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    # required for https urls
curl_setopt($ch, CURLOPT_MAXREDIRS, 15);     

    $html = curl_exec($ch);
    $status = curl_getinfo($ch);
    curl_close($ch);

    if($status['http_code']!=200){
if($status['http_code'] == 301 || $status['http_code'] == 302) {
    list($header) = explode("\r\n\r\n", $html, 2);
    $matches = array();
    preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches);
    $url = trim(str_replace($matches[1],"",$matches[0]));
    $url_parsed = parse_url($url);
    return (isset($url_parsed))? geturl($url):'';
        }
    }
    return $html;
    }
    echo geturl("https://colruyt.collectandgo.be/cogo/nl/zoeken?z=5030");
    ?>
看看


这将打印响应的正文。

在我使用的服务器上不起作用。请求未安装。也许你应该让我们知道你的堆栈是什么。我租了一个directadmin转销商帐户。手动卷曲该页面会返回一些JavaScript和一条消息,请启用JavaScript查看页面内容。这是正确的,有任何修复方法吗?
    var request = require('request');

    request('https://colruyt.collectandgo.be/cogo/nl/zoeken?z=5030', function (error, response, body) {
      console.log(body)
    })