I noticed that all files where named sequentially: 'file_001.zip', 'file_002.zip', ... 'file_xxx.zip'
Instead of downloading files one by one by manually clicking and load pages, I decided to go using PHP.
Here are the instructions and the code:
- First make sure you have a local server on your pc or a remote server with PHP running.
- Suppose you need to download a lof of files which are named sequentially from website: 'file_001.zip', 'file_002.zip', ... 'file_xxx.zip'.
- Create on your local (or remote) server a folder called "downloader" (or any name you like) and put this file in that folder:
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/GPL-license.php GNU Public License
*
*/
@set_time_limit(0);
//@ignore_user_abort(true);
@ini_set('memory_limit', '64M');
page_header('Files Downloader');
$folder_src = 'http://www.targetsite.com/';
$folder_tgt = 'files/';
$filename_base_src = 'file_';
$filename_base_tgt = 'file_';
$files_src = array();
$files_tgt = array();
echo('<br /><br /><br /><h1>Files</h1>');
flush();
echo('<ul>');
for ($i = 1; $i < 1000; $i++)
{
$filename_suffix = str_pad($i, 3, '0', STR_PAD_LEFT);
$filename_src = $filename_base_src . $filename_suffix . '.zip';
$filename_tgt = $filename_base_tgt . $filename_suffix . '.zip';
$filename_full_path_src = $folder_src . $filename_src;
$filename_full_path_tgt = $folder_tgt . $filename_tgt;
//if (@remote_file_exists($folder_src, $filename_src) && @!file_exists($filename_full_path_tgt))
if (@!file_exists($filename_full_path_tgt))
{
$files_src[] = $filename_full_path_src;
$files_tgt[] = $filename_full_path_tgt;
$copy_result = @copy($filename_full_path_src, $filename_full_path_tgt);
echo('<li style="font-size: 9px;">Copying: <b>' . $filename_tgt . '</b> ยป ' . (!empty($copy_result) ? '<span style="color: #228822;">OK</span>' : '<span style="color: #dd2200;">ERROR</span>') . '</li>');
flush();
}
}
echo('</ul>');
echo('<br /><br /><br /><b>Work Complete!!!</b>');
page_footer();
exit;
function page_header($page_title)
{
$encoding_charset = 'UTF-8';
echo('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n");
echo('<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">' . "\n");
echo('<head>' . "\n");
echo(' <meta http-equiv="Content-Type" content="text/html; charset=' . $encoding_charset . '" />' . "\n");
echo(' <meta name="author" content="Luca Libralato" />' . "\n");
echo(' <title>' . $page_title . '</title>' . "\n");
echo('</head>' . "\n");
echo('<body>' . "\n");
echo('<span><a name="top"></a></span>' . "\n");
}
function page_footer()
{
echo('<span><a name="bottom"></a></span>' . "\n");
echo('</body>' . "\n");
echo('</html>');
}
function remote_file_exists($dir, $file)
{
$ret = exec('ls ' . $dir . ' | grep ' . $file);
return (!empty($ret));
}
?>
- I have highlighted the portion of codes you will need to adjust, in particular you need to edit the remote folder where the files are $folder_src = 'http://www.targetsite.com/'; and the base name of the file $filename_base_src = 'file_';
- After having edited the file, you need to create a subfolder called files in the folder you just created (if you have created a folder called downloader, you will then have this path: downloader/files): make sure the files folder has CHMOD 0777 permissions.
- If everything is fine you can then launch the file in your browser and just wait that it finishes to download all your files!
Enjoy!