Skip to content

Instantly share code, notes, and snippets.

@rodurma
Created August 13, 2013 14:25
Show Gist options
  • Select an option

  • Save rodurma/6221604 to your computer and use it in GitHub Desktop.

Select an option

Save rodurma/6221604 to your computer and use it in GitHub Desktop.
Pegando um valor de uma ação através do site da BMF Bovespa
// link: http://www.bmfbovespa.com.br/Pregao-online/ExecutaAcaoCotRapXSL.asp?gstrCA=&txtCodigo=VALE5&intIdiomaXsl=0
// jquery xpath
$('.tdValor:eq(1)').html().replace(/(\r\n|\n|\r| |R\$ )/gm,"").replace(",",".");
// Com PHP e PHPQuery
include "phpQuery.php";
function acao($papel){
$html = file_get_contents("http://www.bmfbovespa.com.br/Pregao-online/ExecutaAcaoCotRapXSL.asp?gstrCA=&txtCodigo=".$papel."&intIdiomaXsl=0");
phpQuery::newDocumentHTML($html, $charset = 'utf-8');
$valor = pq(".tdValor:eq(1)")->html();
return str_replace(",",".",preg_replace("/([^0-9,])/","",$valor));
}
echo acao('VALE5');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment