cURL不适用于指定的站点

时间:2014-09-16 19:06:20

标签: php curl

为什么我的卷发不能正常工作?

$ch = curl_init("http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_resultado.asp");
curl_exec($ch);
curl_close($ch);

3 个答案:

答案 0 :(得分:0)

php.net也使用curl_setopt广告吗?

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_resultado.asp");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>

不确定它是否会起作用

答案 1 :(得分:0)

请尝试以下方法:

$url = "http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_resultado.asp";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec ($ch);
curl_close($ch);

详细解释here

答案 2 :(得分:0)

我发现了解决方案。此链接需要身份验证cookie:

<?php
$ch = curl_init();
$options = array(
    CURLOPT_URL => 'http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_pesquisa_new.asp',
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_MAXREDIRS => 50,
    CURLOPT_COOKIE => 'ASPSESSIONIDCSSRTDCR=KMKMJHPDIHNGBBLJFNGDJKGK; security=true',
    CURLOPT_RETURNTRANSFER => true

);
curl_setopt_array($ch, $options);
$senaHtml = curl_exec($ch);
curl_close($ch);
?>