Advertisement
jessedezwart

Get Billboard Hot 100

Oct 24th, 2013
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. //BY JESSE DE ZWART
  3.  
  4. //Simple script to get Billboard Hot 100 content.
  5. //I'm just a new young coder so change it if you think it can be done better.
  6. //Maybe I'll update for more functions.
  7.  
  8. require_once "simple_html_dom.php";
  9.  
  10. printList(file_get_contents('http://www.billboard.com/charts/hot-100'),1);
  11. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=1'),11);
  12. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=2'),21);
  13. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=3'),31);
  14. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=4'),41);
  15. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=5'),51);
  16. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=6'),61);
  17. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=7'),71);
  18. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=8'),81);
  19. printList(file_get_contents('http://www.billboard.com/charts/hot-100?page=9'),91);
  20.  
  21.  
  22. function printList($html,$i) {
  23.     $html = str_get_html($html);
  24.     foreach($html->find('div') as $element) {
  25.         if ($element->class == "listing chart_listing") {
  26.             $lijst = $element;
  27.         }
  28.     }
  29.  
  30.     foreach($lijst->find('article') as $element) {
  31.         $title = $element->find('h1');
  32.         $artist = $element->find('a');
  33.  
  34.         $artist = $artist[0]->plaintext;
  35.         $title = trim($title[0]->plaintext);
  36.        
  37.         echo $i;
  38.         echo "<br>";
  39.         echo $artist;
  40.         echo "<br>";
  41.         echo $title;
  42.         echo "<br><br>";
  43.        
  44.         $i = $i + 1;
  45.     }
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement