Last active
August 29, 2015 13:59
-
-
Save felipsmartins/10490098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reconstói todo o conteúdo HTML sob $node; | |
* em resumo, isso funciona como innerHTML do Javascript | |
* | |
* @param DOMNode $node | |
* @return string Conteúdo HTML reconstruído | |
*/ | |
function dom_reconstruct(DOMElement $node){ | |
$dom = new DOMDocument(); | |
$dom->appendChild($dom->importNode($node, true)); | |
return $dom->saveHTML(); | |
} | |
$query_params = '?versao=2.00&tipoConteudo=Skeuqr8PQBY='; | |
$url = 'http://www.nfe.fazenda.gov.br/PORTAL/disponibilidade.aspx'; | |
$url .= $query_params; | |
$request_content = file_get_contents($url); | |
$dom = new DOMDocument(); | |
@$dom->loadHTML($request_content); | |
$xpath = new DOMXPath($dom); | |
$query = '//table[@id="ContentPlaceHolder1_gdvDisponibilidade"]'; | |
$entries = $xpath->query($query); | |
$table = $entries->item(0); | |
print dom_reconstruct($table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment