HHEELLLLPPP!! remote site have changed code

Discussion in 'PHP' started by webber09, Oct 11, 2009.

  1. #1
    i was using the below codes for ages to 'steal' the top 10/40 singles from Radio 1 page, and now they have suddenly decided to change there coding... would anyone please be able to adapt mine to 'steal' theres once again...

    Thanks in advanced

    <?php
    $data = file_get_contents("http://www.bbc.co.uk/radio1/chart/singles.shtml");
    preg_match_all('%<td class="col1">(\d+?)</td>.+?src="(.+?)".+?<h4>(.+?)</h4>.+?<h5>(.+?)</h5>%sm', $data, $result, PREG_PATTERN_ORDER);
    $num_elements = count($result);
    ?>
    
    <?php
    for($i = 0; $i < 10; $i++) {
    echo "<tr><td class='td2' align='center'>".$result[1][$i]."</td><td class='td2' align='center'><img src='".$result[2][$i]."' width='70' height='70' alt='' border='0' /> </td><td class='td2' align='center'>".$result[3][$i]."</td><td align='center'>".$result[4][$i]."</td></tr>";
    }
    ?>
    PHP:
    there new website address is http://www.bbc.co.uk/radio1/chart/singles/
     
    webber09, Oct 11, 2009 IP
  2. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I think this will do what you want:
    <?php
    $data = file_get_contents("http://www.bbc.co.uk/radio1/chart/singles/");
    preg_match_all('/<span class="position">(\d+?)\s*<\/span>.+?src="(.+?)".+?<span class="artist">(.+?)\s*<\/span>.+?<span class="track">(.+?)\s*<\/span>/sm', 
    $data, 
    $result);
    $num_elements = count($result);
    
    
    ?>
    
    <?php
    for($i = 0; $i < 10; $i++) {
    echo "<tr><td class='td2' align='center'>".$result[1][$i]."</td><td class='td2' 
    align='center'><img src='".$result[2][$i]."' width='70' height='70' alt='".$result[3][$i]."' border='0' 
    /> </td><td class='td2' align='center'>".$result[3][$i]."</td><td 
    align='center'>".$result[4][$i]."</td></tr>";
    }
    ?>
    PHP:
     
    superdav42, Oct 12, 2009 IP
  3. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    Amazing Thank you superdav42 !!! worked like a charm =]
     
    webber09, Oct 12, 2009 IP
  4. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #4
    THEY HAVE CHANGED THERE CODE SLIGHTLY AGAIN!!!

    i am still using the above code however the images are now NOT working, i believe they have changed the way they link the images

    can anyone help plz :D
     
    webber09, Apr 24, 2011 IP
  5. blakeembrey

    blakeembrey Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here you go, they just removed "http://www.bbc.co.uk/" from there own image string.

    <?php
    for($i = 0; $i < 10; $i++) {
    echo "<tr><td class='td2' align='center'>".$result[1][$i]."</td><td class='td2'
    align='center'><img src='http://www.bbc.co.uk/".$result[2][$i]."' width='70' height='70' alt='".$result[3][$i]."' border='0'
    /> </td><td class='td2' align='center'>".$result[3][$i]."</td><td
    align='center'>".$result[4][$i]."</td></tr>";
    }
    ?>
     
    blakeembrey, Apr 24, 2011 IP
  6. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #6
    thank you so much :D star!
     
    webber09, Apr 25, 2011 IP
  7. blakeembrey

    blakeembrey Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    No problem, it was an extremely easy fix ;)
     
    blakeembrey, Apr 25, 2011 IP