Personally I'm basically trying to get some data from SEFAZ, to check if it is online or unavailable at the moment I'm not getting it because I do not know, I wonder how I can get a certain line of their code?
Personally I'm basically trying to get some data from SEFAZ, to check if it is online or unavailable at the moment I'm not getting it because I do not know, I wonder how I can get a certain line of their code?
You can use get_http_response_code
to check that the page is online and then file_get_contents
to download the page.
if(get_http_response_code('http://sefaz.com') != "200"){
echo "erro";
}else{
$pagina = file_get_contents('http://sefaz.com');
}
To find a certain line after downloading the page, in this case the choice of the AP is by the content of the MT line the library SIMPLE_HTML_DOM_PARSER
<?php
include '../../../library/Simple_HTML_DOM/simple_html_dom.php';
$html = file_get_html( 'http://www.nfe.fazenda.gov.br/portal/disponibilidade.aspx?versao=0.00&tipoConteudo=Skeuqr8PQBY=' );
$tdMT = NULL;
foreach($html->find('td') as $td){
if($td->innertext === 'MT'){
$tdMT = $td->parent();
foreach($tdMT->find('td') as $td){
echo $td->innertext . '<br>';
}
}
}
?>
What's being done:
Simple_HTML_DOM
td
td
is the desired one (in the case MT ) td
in case to tr
td
daughter of tr
(any computation could be done) * Note: There is also plain text such as MT and - HTML tags within td
.
Link to library download: Link