PHP content 'steal'

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

  1. #1
    i am hoping to set up a top 40 uk chart page on my website.

    however i do not want to have to sit there for hours every week and type it all up. Is there a script that i can use to 'steal'/copy the information and display/generate the page for me?

    thanks in advanced =]
     
    webber09, Oct 2, 2009 IP
  2. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #2
    You should probably check PHP extension cURL and function preg_match (preg_match_all)
     
    Gray Fox, Oct 2, 2009 IP
  3. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    so if i were wanting to take the information in the chart, from http://www.bbc.co.uk/radio1/chart/singles.shtml, how would i do this?
     
    webber09, Oct 2, 2009 IP
  4. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #4
    do you want copy pictures to your hosting ? Or do you want use links to the pictures ?

    Grab the source code, and study the structure of the page . I had quick view on page , I see the artists content starts with <!-- Start Entry data -->

    the content :

    <!-- Start Entry data -->

    <tr>


    <td class="col1">1</td>
    <td class="col2">1</td>
    <td class="col3">2</td>

    <td class="col4">

    <img src="http://www.bbc.co.uk/radio1/media/images/artists/taio_cruz/090918_cd_heart_70.jpg" width="70" height="70" alt="" border="0" />

    <h4>Taio Cruz</h4>
    <h5>Break Your Heart</h5>

    <p>(Island)<br />
    <a href="http://www.taiocruzmusic.co.uk">http://www.taiocruzmusic.co.uk</a></p>
    </td>

    </tr>

    <!-- End Entry data -->


    You have to crawl through the page
     
    Last edited: Oct 2, 2009
    ziya, Oct 2, 2009 IP
  5. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #5
    ziya,

    is it possible to just make a link to the images?

    also would it be possiable to just get:

    Taio Cruz
    Break Your Heart

    rather than:

    Taio Cruz
    Break Your Heart
    (Island)
    http://www.taiocruzmusic.co.uk

    thanks again
     
    webber09, Oct 2, 2009 IP
  6. Sawney

    Sawney Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Never link to someone else's images.
     
    Sawney, Oct 2, 2009 IP
  7. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #7
    ziya, Oct 2, 2009 IP
  8. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #8
    Run this code and see what info you nedd from $result array
    
    $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);
    print_r($result);
    
    PHP:
    It works fine only for 10 first songs :)
     
    AsHinE, Oct 2, 2009 IP
  9. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #9
    the above shows up as http://infectionfm.co.uk/test.php

    please advise
     
    webber09, Oct 2, 2009 IP
  10. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #10
    yes it works :)
    so you have places in $result[1], pics in $result[2], artists in $result[3] and songs in $result[4].
    So you got info - do everything you want wtih it.
     
    AsHinE, Oct 2, 2009 IP
  11. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #11
    thank you very much AsHinE

    just one question:

    where
    [number] =>
    Code (markup):
    is shown. how do i get rid of them ?

    sorry but i am relativity new to this
     
    webber09, Oct 2, 2009 IP
  12. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #12
    Use some thing like this :

    echo $result[1][0]."<img src='".$result[2][0]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][0]."<br>".$result[4][0];

    and use it in a loop
     
    ziya, Oct 2, 2009 IP
  13. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #13
    i have put

    
    
    $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);
    
    echo $result[1][0]."<img src='".$result[2][0]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][0]."<br>".$result[4][0];
    
    
    PHP:
    in my test page (show here http://infectionfm.co.uk/test.php) and it displayes the Number 1.

    how would i go about putting it into the loop to get the Numbers 1-10?
     
    webber09, Oct 2, 2009 IP
  14. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #14
    Try this :

    $num_elements = count($result);

    for($i = 0; $i < $num_elements; $i++) {
    echo $result[1][$i]."<img src='".$result[2][$i]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][$i]."<br>".$result[4][$i]."<br>";
    }
     
    ziya, Oct 2, 2009 IP
  15. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #15
    i now have the coding below in the test.php (shown on http://infectionfm.co.uk/test.php) and it displays the top 5... how is it possiable to change it to show top 10?

    $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);
    
    for($i = 0; $i < $num_elements; $i++) {
    echo $result[1][$i]."<img src='".$result[2][$i]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][$i]."<br>".$result[4][$i]."<br>";
    }
    PHP:
     
    webber09, Oct 2, 2009 IP
  16. ziya

    ziya Well-Known Member

    Messages:
    1,971
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #16
    try this :

    for($i = 0; $i < 10; $i++) {
    echo $result[1][$i]."<img src='".$result[2][$i]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][$i]."<br>".$result[4][$i]."<br>";
    }
    ___
     
    ziya, Oct 2, 2009 IP
  17. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #17
    a missive thank you to all of you. just shows how we can all contribute to get things done =]

    if you want to see my final version of the script then go to http://infectionfm.co.uk/top40/

    again thanks you everyone
     
    webber09, Oct 2, 2009 IP
  18. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #18
    i was using the above/below codes for 2weeks 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 it to 'steal' theres once again...

    Thanks in advanced

    $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);
    
    for($i = 0; $i < 10; $i++) {
    echo $result[1][$i]."<img src='".$result[2][$i]."' width='70' height='70' alt='' border='0' /> <br>".$result[3][$i]."<br>".$result[4][$i]."<br>";
    }
    PHP:
     
    webber09, Oct 12, 2009 IP
  19. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #19
    i have now fixed this problem... thanks anyway people
     
    webber09, Oct 12, 2009 IP
  20. silotka

    silotka Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    if you fixed, then show your solution, maybe someone could learn from you!
     
    silotka, Oct 14, 2009 IP