g3x0

JSON from Google Finance

Sep 21st, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. header('Access-Control-Allow-Origin: *');
  3. preg_match('#<div id=currency_converter_result>.*?<span class=.*?>(.*?)\s#s', file_get_contents('https://www.google.com/finance/converter?from=' . @$_GET['from'] . '&to=' . @$_GET['to'] . '&a=' . @$_GET['q']), $res);
  4.  
  5. $to = @$_GET['to'];
  6. $from = @$_GET['from'];
  7. $v = @$res[1];
  8.  
  9. echo '{"to": "' . $to . '", "from": "' . $from .'", "v": ' . $v . '}';
Add Comment
Please, Sign In to add comment