1
Guys 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 up because I don’t know, I wonder how I can is picking up a certain line of their code ?
1
Guys 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 up because I don’t know, I wonder how I can is picking up a certain line of their code ?
4
You can use the get_http_response_code
to check if 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 AP is by the line content MT the library shall be used 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 is being done:
Simple_HTML_DOM
td
td
is the desired (in case MT)td
in case the tr
td
daughter of tr
(could be done any computation)*Note: There is besides plain text as MT and - HTML tags inside the td
.
Link to download library: Link
Browser other questions tagged php html
You are not signed in. Login or sign up in order to post.
yes but however I just want to, take a line inside HTML DELE, Saka type I want the <div class="texte"> </div> an example. how do I do ?
– Edward Junior
yes this instead of being the whole site I just want an example line <div class="texte"> <H1> status of Sefaz : .......... </H1></div>
– Edward Junior
http://www.nfe.fazenda.gov.br/portal/availabilityaspx?versao=0.00&tipoConteudo=Skeuqr8PQBY= get on this link I want to pick up the line Where it is written MT whole it
– Edward Junior
how I came to not understand ?
– Edward Junior
@Edwardjunior I edited my reply, the official website this offline momentarily I can upload in the lib Dropbox if you want
– Ricardo
@Edwardjunior uploaded the lib to Dropbox: https://www.dropbox.com/s/2tzwpcv5zg7y1nr/simple_html_dom.php?dl=0
– Ricardo
Thank you very much guy worked, but I ask you how I can make an IF NESSE Instead of him bring everything he just gives an ACTIVE OR INACTIVE response , Example If ( the ball is green ) ACTIVE / If No (green ball) Inactive ?
– Edward Junior