views:

30

answers:

1

I want to get all midi (*.mid) files from a site that's set up pretty simple in terms of directory tree structure. I wish we had wget installed here, but that's another party....

The site is VGMusic.com and the path containing all of the midi files is:

http://www.vgmusic.com/music/console/nintendo/nes/

I tried glob'ing it out, but I suppose that glob only works locally?

Here is what I wrote to try to make it happen (doesn't work.. obviously..):

<?php 
echo 'not a blizzard<br>';
foreach(glob('http://www.vgmusic.com/music/console/nintendo/nes/*.mid') as $filename)
{
    echo $filename.'<br>';
    //$newfile = 'http://www.mydomain.com/nes/'.$filename;
    //copy($filename, $newfile)
}
?>

I tried it also without the http:// in there with no luck.

+1  A: 

Indeed glob only works on the local filesystem.

In your case you have to parse the page http://www.vgmusic.com/music/console/nintendo/nes/index-classic.html and search for strings that look like href="(*.mid)" and after that request those urls.

This is a good example of a regexp that should perform reasonably well: http://www.the-art-of-web.com/php/parse-links/

However, if you just want to have all those files I'd say you better use some sort of 'download all' browser plugin.

Simon Groenewolt
thats not a bad idea - the plugin, ill check both out
CheeseConQueso
https://addons.mozilla.org/en-US/firefox/addon/220 worked good, but im still going to try the php method so i can avoid the extra step of ftp'ing the dl'd files over
CheeseConQueso