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 =]
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?
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
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
Yes it is possible.. As you see here : <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" /> And yes it is possible just grab the only : Taio Cruz Break Your Heart Bold text is the link the picture . If you will copy it and open it in your browser yuo will se the picture. So you can use this as a link to picture ( http://www.bbc.co.uk/radio1/media/images/artists/taio_cruz/090918_cd_heart_70.jpg )
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
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.
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
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
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?
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>"; }
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:
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>"; } ___
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
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: