2017-07-02 18 views
0

我想使用来自使用报表查看器的页面的数据,并且我的CURL代码没有找到此查看器的数据。从报表查看器中使用PHP和CURL进行刮取

Page URL

页属于这个网站:fiscalizandocomtce

<?php 
    $curl = curl_init("http://reportviewer.tce.mg.gov.br/default.aspx?server=noruega&relatorio=SICOM_Consulta%2f2017%2fModulo_AM%2fDetalhamentos%2fUC31-DetContratos-RL&contrato=8678102&periodoSelecionado=0&remessaSelecionada=662325639,668743165,674898703,675479698,682749064,682749296,682752194,684843149,687617053,689543045,689556683,689827842,690502542&orgaoSelecionado=11938&exercicioSelecionado=2017"); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 

    $page = curl_exec($curl); 

    if(curl_errno($curl)) // check for execution errors 
    { 
     echo 'Scraper error: ' . curl_error($curl); 
     exit; 
    } 

    echo $page; 
?> 

我已经使用过simple_html_dom试过,但它也不能从问题的网页的报表浏览器捕获数据。

<?php 

include('simple_html_dom.php'); 

$html = file_get_html('http://reportviewer.tce.mg.gov.br/default.aspx?server=noruega&relatorio=SICOM_Consulta%2f2017%2fModulo_AM%2fDetalhamentos%2fUC31-DetContratos-RL&contrato=8678102&periodoSelecionado=0&remessaSelecionada=662325639,668743165,674898703,675479698,682749064,682749296,682752194,684843149,687617053,689543045,689556683,689827842,690502542&orgaoSelecionado=11938&exercicioSelecionado=2017'); 

// extract text from HTML 
echo $html->plaintext; 
?> 

除了我提到的两个之外,还有其他方法可以做到吗? 感谢您的帮助!

+0

https://github.com/guzzle/guzzle – mkaatman

回答

0

首先检查网址是否在浏览器中打开。 其次是的file_get_contents ,你可以使用DOMDocument类PHP的遍历HTML文档和刮所需要的数据

+0

感谢您的回答。我在报告数据后更改为file_get_contents。我也不明白在我的浏览器中打开的链接是否可以干扰? – ffaelcdec