Page 1 of 1

Load info from span tag

Posted: Mon Aug 21, 2006 11:02 am
by Tomcat7194
Hello. I'm looking for a way to get the average US gas price from the site Gasbuddy.com using PHP. After looking at the source code of the site, I found that the average price is contained within a specific <span> tag:

Code: Select all

<span id="GBPS_lblUSToday">2.911</span>
Is there a way to use PHP to load the number contained within the <span> tag, then make it into a variable that I can use in calculations?

Thanks
Tom

Posted: Mon Aug 21, 2006 11:13 am
by feyd
Yes, there is. 2 × strpos() + substr() or preg_match().

Posted: Mon Aug 21, 2006 12:46 pm
by Weirdan
feyd, was that your new template answer? Image

Posted: Mon Aug 21, 2006 12:48 pm
by feyd
Weirdan wrote:feyd, was that your new template answer? Image
Oddly it seems to fit a lot of questions. Image