Know the path saved by the server slice and how to batch download the class to the local device. The 850 folder and 014 file names both match from 000, and the file will be downloaded if it exists, otherwise skipped: the following code can only download the specified page: (, hope... know the path where the server slice is saved and how to batch download it to the local device. The 850 folder and 014 file names both start matching from 000. If the file exists, it will be downloaded. Otherwise, it will be skipped.
The following code can only download the specified page: (Thank you !)
The following code can only download the specified page: (Thank you!
Availablecurl_multi_*
Batch Request Remote addresses for series functions. Put all the pages to be requested in an array, and send 20 concurrent requests at a time.
We recommend that you modify the program idea. First, obtain the image addresses to be downloaded in batches Based on the page address, and then process the image downloads in batches.
Both parts can be used.culr_multi_*
Series functions are processed concurrently.
It's too bad to generate a copy of the code. You can try again later.
Used multiple times in a cycleaddPage
That's all.
If you already have a url, you can use it directly.download
.
for ($i = 0; $i < 99; ++$i) download('http://cdn.image.com/static/' . $i . '.png', DOWNLOAD_PATH . $i . '.png');
The efficiency is a little low. You can use the test token instead.culr_multi_*
Series function.
$referer) { // echo $url, "\n"; $filename = pathinfo($url, PATHINFO_FILENAME) . '.' . pathinfo($url, PATHINFO_EXTENSION); download($url, $path . $filename, $referer); } // error_reporting(1);}function addPage($page, &$urls) { $cur = extractPage($page); for ($i = 0, $n = count($cur); $i < $n; ++$i) { $j = $cur[$i]; if (!isset($urls[$j])) $urls[$j] = $page; }}function extractPage($page, $reg = '//') { $content = file_get_contents($page); // $content = ''; preg_match_all($reg, $content, $matches); return $matches[1];}function download($url, $file, $referer = '') { $url = abs_url($url, $referer); echo $url, "\n"; $opts = [ 'http' => [ 'method' => 'GET', 'header' => "Accept-language: en\r\n" . // "Cookie: \r\n" . "Referer: " . $url . "\r\n" ] ]; $context = stream_context_create($opts); file_put_contents($file, file_get_contents($url, false, $context)); return $file;}function abs_url($url, $referer) { $com = parse_url($url); if (!isset($com['scheme'])) $com['scheme'] = 'http'; if ($referer !== '') { $ref = parse_url($referer); if (!isset($com['host'])) { if (isset($ref['host'])) { $com['host'] = $ref['host']; if (!isset($ref['path'])) $ref['path'] = '/'; } if (isset($com['path'][0])) { if ($com['path'][0] !== '/') $com['path'] = $ref['path'] . $com['path']; } else if (isset($ref['host'])) { $com['path'] = $ref['path']; } } else { if (!isset($com['path'])) $com['path'] = ''; } } return unparse_url($com);}function unparse_url($com) { return (isset($com['host']) ? ($com['scheme'] . '://' . $com['host']) : '') . $com['path'] . (isset($com['query']) ? '?'.$com['query'] : '');}