Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get values from a url's div class variable 1

Status
Not open for further replies.

akgta

Programmer
Jul 18, 2007
42
CA
How to get values from a url's div class variable:

for example:

if we want temperature value of Chicago IL from cnn.com/weather the url is:


and under this url there is a div class variable:
cnnWeatherTempCurrent

this variable contains the value of the current temperature.

so using HTML or Javascript or PHP how can we get the value of this variable in our web page

Your help is highly appreciated.
 
Hi

Code:
preg_match(
  '/.*WeatherTempCurrent">(\d+)&deg;<.*/m',
  file_get_contents($the_url_here),
  $match
);
echo $match[1];
Notes :
[ul]
[li]Using the above code may infringe copyrights.[/li]
[li]Works with PHP 5 or newer.[/li]
[/ul]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top