View Full Version : Content Extracting
02-11-2006, 02:20 AM
Okay, I have a personal NASCAR league in the works, and I am sick of updating the records myself. So, I wanted to pull the content from this page:
and read the standings then update my own table.
So far I've got:
Now my question is - Should I use preg_match_all to scan through the TD's?
or is there a better method?
Any ANY help is greatly appreciated! :)
02-11-2006, 05:34 AM
I was bored so here you go, you can format the table however you like....let me know if you have questions:
$myfile = file_get_contents("http://www.nascar.com/races/cup/2005/data/standings_official.html");
$start = strpos($myfile, "Winnings");
$finish = strpos($myfile, "* Denotes Rookie");
$length = $finish - $start;
$string = substr($myfile,$start,$length);
$string = str_replace('>','>~',$string);
$string = str_replace('</tr>','</tr>^',$string);
$string = strip_tags($string);
$string = substr($string,10);
$lines = explode("^",$string);
print "<table cellpadding=5>";
foreach ($lines as $key => $val)
if (strlen($val) < 30)
$data = explode("~",$lines[$key]);
foreach ($data as $key => $val)
if ($val == "" || $val =="*")
print "<td>" . $val . "</td>";
02-11-2006, 07:18 PM
Hey chump2877, THANK YOU SO MUCH! Sweet! :D
02-11-2006, 10:31 PM
you're welcome :thumbsup:
hopefully you understand how the code works...you don;t need to use regular expressions for what you want to do....
02-11-2006, 10:34 PM
Yes, I do understand the code, you have open my eyes :D
This is great! thanks!
02-12-2006, 09:33 PM
Though, regular expressions would shorten the code probably by 3/4 and speed up the script.
02-13-2006, 04:05 AM
Right now speed isnt' an issue, but for future reference, do you have some code?? Would like to see hwo its done.
02-13-2006, 04:28 AM
regex gives me headaches, that's why i didn't use it....:D
02-13-2006, 06:25 AM
Me two man, but good to learn hehe :D
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.