Created
March 17, 2015 14:50
-
-
Save pingyen/1a4d3aef76d818cfb7a0 to your computer and use it in GitHub Desktop.
Xuite Photo Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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