getting info fro site

Discussion in 'PHP' started by deemainer, Dec 15, 2008.

  1. #1
    hi all

    can anyone point me in the right direction please.What id like to be able to do get access to the info from

    www.tfl.gov.uk/tfl/syndication/feeds/serviceboard-fullscreen.htm

    id like to be able to present in my own manner on a site.Can anyone tell me what i need to learn to be able to do it? Probably a huge question but any pointers appreciated.

    cheers
     
    deemainer, Dec 15, 2008 IP
  2. SeanBlue

    SeanBlue Peon

    Messages:
    110
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you just want to display the information on that page you could do it with an iframe instead of using PHP.

    If you want to collect the data and display it in a different format, you'd need to open and then collect the contents of the page and display them in a new manner.

    Check out PHP.net entries for fopen and fread to open the page and check out explode and preg_match to collect the data.
     
    SeanBlue, Dec 15, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Ideal code? No. Decent code? Yes.

    <?php
    
    define( 'PAGE', 'http://www.tfl.gov.uk/tfl/syndication/feeds/serviceboard-fullscreen.htm' ); /* Page URL */
    define( 'STATIONS', 11 );   /* How many stations */
    define( 'FIRST_LINE', 65 ); /* Normal form, first line = line 1, etc */
    
    $page = explode( "\n", preg_replace( "/(\n)+/", "\n", str_replace( array("\t", "\r", '&amp; '), '', strip_tags( file_get_contents( PAGE ) ) ) ) );
    
    for ( $i = FIRST_LINE - 1, $end = FIRST_LINE - 1 + STATIONS * 2, $stations = array(); $i < $end; $i = $i + 2 )
        $stations[$page[$i]] = $page[$i + 1];
    
    print_r( $stations );
    
    ?>
    PHP:
    Returns (obviously dependent on time):

    Array
    (
        [Bakerloo] => Good service
        [Central] => Good service
        [Circle] => Good service
        [District] => Good service
        [H'smith City] => Good service
        [Jubilee] => Good service
        [Metropolitan] => Good service
        [Northern] => Good service
        [Piccadilly] => Good service
        [Victoria] => Good service
        [Waterloo City] => Planned closure
    )
    Code (markup):
     
    Danltn, Dec 15, 2008 IP
  4. deemainer

    deemainer Active Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #4
    Thank you so much for taking the time to do that Danltn and also Seanblue. Very good of you and much appreciated. I now have a starting place and a good idea of what's needed. Thank you.
     
    deemainer, Dec 16, 2008 IP