For the Top-40 charts, you just need to make a script that pulls the data (using
file_get_contents or
cURL - I advise
cURL because you can set multiple parameters like spoofing user-agent, multiple url fetch etc), then you scrape the data.
By scraping, I mean you study the HTML structure then parse the DOM using a robust HTML parser like
simple html dom,
QueryPath,
PHPQuery and others you may think of or just use
libxml(but I propose a HTML parser because of the shallow learning curve and the CSS3 selectors. But choose wisely, some of them have bad memory leaks...e.g simple html dom depending on the level and looping when parsing).
Dom't use Regular expressions to parse HTML. After that, have the script store the data in the Database. Then to have the data 'automatically update' set the script to run after a certain amount of time using a cronjob. Make sure to space it out well to prevent your server's IP from being blocked.