Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Parsing HTML

Posted on 2007-03-23
5
Medium Priority
?
178 Views
Last Modified: 2013-12-13
Is it possible to parse an html page to pull a specific number off that page. The number follows immediately after the keyword "Big Number" in the following form:

Big Number:&nbsp;<b>309</b>

Is it possible to parse the page with PHP, search for that keyword, and then put the number into a variable to be stored in a database?
0
Comment
Question by:jfredrickson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:JamesCssl
ID: 18784175
$string = 'whatever here Big Number:&nbsp;<b>309</b>whateverhere'
preg_match('/Big Number:&nbsp;<b>([0-9]+)<\/b>/s',$string,$matches);
echo $matches[1];
0
 
LVL 4

Author Comment

by:jfredrickson
ID: 18784204
Cool, how do I get the html from an external URL into the $string variable to parse it?
0
 
LVL 11

Accepted Solution

by:
JamesCssl earned 2000 total points
ID: 18784211
$handle = fopen("http://www.example.com/", "r");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
$string = $contents;
0
 
LVL 4

Author Comment

by:jfredrickson
ID: 18784215
You're my hero!
0
 
LVL 11

Expert Comment

by:JamesCssl
ID: 18784218
glad to help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question