Skip to content

Instantly share code, notes, and snippets.

@felipsmartins
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipsmartins/10490098 to your computer and use it in GitHub Desktop.
Save felipsmartins/10490098 to your computer and use it in GitHub Desktop.
<?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