Load info from span tag

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tomcat7194
Forum Commoner
Posts: 48
Joined: Mon Jul 31, 2006 1:34 pm

Load info from span tag

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yes, there is. 2 × strpos() + substr() or preg_match().
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

feyd, was that your new template answer? Image
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Weirdan wrote:feyd, was that your new template answer? Image
Oddly it seems to fit a lot of questions. Image
Post Reply