Created
August 13, 2013 14:25
-
-
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
This file contains hidden or 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
| // 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