Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created March 17, 2015 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/1a4d3aef76d818cfb7a0 to your computer and use it in GitHub Desktop.
Save pingyen/1a4d3aef76d818cfb7a0 to your computer and use it in GitHub Desktop.
Xuite Photo Downloader
<?php
$user = 'demo';
$html = '';
for ($i = 1; $i <= 100; ++$i) {
$html .= file_get_contents("http://photo.xuite.net/$user*$i");
}
$tokens = array_slice(explode('<p class="album_info_title">', $html), 1);
$albums = array();
foreach ($tokens as $token) {
$token = ltrim($token);
$albums[] = array(
'id' => substr($token, 38, strpos($token, '">') - 38),
'count' => intval(substr($token, strpos($token, '共') + 3)),
'photos' => array()
);
}
$sum = 0;
foreach ($albums as &$album) {
$id = $album['id'];
$count = $album['count'];
$photos =& $album['photos'];
$sum += $count;
echo "$id, $count\n";
for ($i = 1; $i <= $count; ++$i) {
$html = file_get_contents("http://photo.xuite.net/$user/$id/$i.jpg/sizes/o/");
$token = substr($html, strpos($html, '<img src="http://o.') + 10);
$photo = substr($token, 0, min(strpos($token, '?'), strpos($token, '"')));
$photos[] = $photo;
$file = substr($photo, strrpos($photo, '/') + 1);
if (file_exists($file) === false) {
echo "$i, $photo\n";
shell_exec("curl -O --referer http://photo.xuite.net $photo");
}
}
}
echo "$sum\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment