Re: looking for source to pull data (price of oil)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kurrent wrote:

> I am just simply looking for the price of nymex crude future ( see
> http://www.bloomberg.com/energy/).
> 
> Any sources or other idea would be much appreciated. Thanks!

This seems to work:

<?php

ini_set("user_agent", "Mozilla/5.0"); 
$page = strip_tags(file_get_contents("http://www.bloomberg.com/energy/";));
$search = "Nymex Crude Future";
$start = strpos($page, $search) + strlen($search);
$price = floatval(substr($page, $start, 5));

echo($price);

?>

It assumes a. the Bloomberg page will stay the same, b. the Nymex price 
will always be 5 characters and c. that this is for private use, because 
Bloomberg is likely going to be very unhappy about you republishing their 
data.

That said, I would personally have no qualms using this for a limited 
scope intranet application for instance.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux