[转]用PHP下妹子图

  • 发表于
  • PHP

直接在PHP下执行就行了:php x.php
14

[\s]*[\s]*<\/a>[\s]*<\/div>[\s]*

(.*)
<\/p>/', $html, $matchs); $links = array(); if(count($matchs) > 2){ foreach ($matchs[2] as $k => $v) { $links[$v] = $matchs[1][$k]; } } return $links; } function getImgUrls($url){ $html = file_get_contents($url); preg_match_all('', $html, $matchs); return count($matchs) > 1 ? $matchs[1] : null; } function getImage($path, $url){ preg_match('/==\/(\w+)\.jpg/', $url, $match); $filepath = $path . DIRECTORY_SEPARATOR . $match[1] . '.jpg'; ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $fp=@fopen($filepath, 'a') ; fwrite($fp, $img); fclose($fp) ; } while($page <= $max_page){ echo '>>> Start download page ' . $page . PHP_EOL; $url = $base_url . $page; $html = file_get_contents($url); $links = getLinks($html); echo '>>> Find ' . count($links) . ' atlas' . PHP_EOL; foreach ($links as $k => $v) { $k = str_replace(' ', ' ', $k); if(!file_exists($k)){ echo '>>> Make directory ' . $k . PHP_EOL; mkdir($k, 0755, true); } $img_urls = getImgUrls($v); foreach ($img_urls as $key => $value) { echo '>>> Downloading ' . $value . PHP_EOL; getImage($k, $value); } } $page++; }