Skip to content

Instantly share code, notes, and snippets.

@sotarok
Created May 11, 2009 17:08
Show Gist options
  • Save sotarok/110052 to your computer and use it in GitHub Desktop.
Save sotarok/110052 to your computer and use it in GitHub Desktop.
<?php
$ids = array(
'1217330732',
'1196052839',
'1191016305',
'1114782154',
'1182842477',
'1160202787',
);
foreach ($ids as $id) {
$xml = @simplexml_import_dom(DOMDocument::loadHTMLFile("http://www.b-idol.com/read.cgi/bbs/$id/"));
echo "starting $id :\n";
foreach ($xml->xpath('//a[@target="photo"]//img') as $photo) {
$photo_url = str_replace(array("../", "s00"), array("", "00"), $photo->attributes()->src);
$photo_url = "http://www.b-idol.com/" . $photo_url;
$file_name = $id . "_" . basename($photo_url);
echo " " . $photo_url ." ... ";
if (!file_exists($file_name) || filesize($file_name) == 0) {
file_put_contents($file_name, file_get_contents($photo_url), FILE_BINARY);
echo " done.\n";
}
else {
echo " skipped.\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment