Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Content Extracting

    Hey all,

    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:

    http://www.nascar.com/races/cup/2005..._official.html

    and read the standings then update my own table.

    So far I've got:
    Code:
    $myfile=file_get_contents("http://www.nascar.com/races/cup/2005/data/standings_official.html");
    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!
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    I was bored so here you go, you can format the table however you like....let me know if you have questions:


    PHP Code:
    <HTML>
    <HEAD>
    <TITLE></TITLE>

    </HEAD>

    <BODY>


    <?

    $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);

    trim($string);

    $lines explode("^",$string);

    print 
    "<table cellpadding=5>";

    foreach (
    $lines as $key => $val)
    {
        if (
    strlen($val) < 30)
        {
            unset(
    $lines[$key]);
            continue;
        }

        
    $data explode("~",$lines[$key]);

        print 
    "<tr>";

        foreach (
    $data as $key => $val)
        {
            if (
    $val == "" || $val =="*")
            {
                unset(
    $data[$key]);
                continue;
            }

            print 
    "<td>" $val "</td>";
        }

        print 
    "</tr>";
    }


    print 
    "</table>";


    ?>


    </BODY>
    </HTML>
    Last edited by chump2877; 02-11-2006 at 09:08 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey chump2877, THANK YOU SO MUCH! Sweet!
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    you're welcome

    hopefully you understand how the code works...you don;t need to use regular expressions for what you want to do....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I do understand the code, you have open my eyes

    This is great! thanks!
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #6
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Though, regular expressions would shorten the code probably by 3/4 and speed up the script.

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Element,

    Right now speed isnt' an issue, but for future reference, do you have some code?? Would like to see hwo its done.
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #8
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    regex gives me headaches, that's why i didn't use it....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Me two man, but good to learn hehe
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •