Wget return downloaded filename?

Maybe that's some kind of cheating but why not.

Maybe that's some kind of cheating, but why not : decide yourself the name of the file that wget should create indicate to wget that the download should be made to that file when the download is finished, use that file -- as you already know the name. Check out the -O option of wget ;-) For example, running this from the command-line : wget 'google.com/' -O my-output-file. Html Will create a file called my-output-file.html.

Mar 23 '10 at 5:43 Good solution, but I should have clarified that the target of wget may be an image or stylesheet, or any other file. I updated the question to reflect this. – Matthew Mar 23 '10 at 21:12.

If your requirement is simple like just getting google.com, then do it within PHP $data=file_get_contents('http://www. Google.com/'); file_put_contents($data,". /downloads/output.

Html").

On Linux like systems you can do: system('/usr/bin/wget -q --directory-prefix=". /downloads/" google.com/'); $filename = system('ls -tr . /downloads'); // $filename is now index.

Html This works if there is no other process creating file in the . /downloads directory.

How about PHP's own readdir() or glob() – ghostdog74 Mar 23 '10 at 5:54 I ended up doing something similar, but avoided the system call. To get the most recently updated file, I used this code: code $dir = ". /downloads"; $newstamp = 0; $newname = ""; $dc = opendir($dir); while ($fn = readdir($dc)) { # Eliminate current directory, parent directory if (ereg('^\.

{1,2}$',$fn)) continue; $timedat = filemtime("$dir/$fn"); if ($timedat > $newstamp) { $newstamp = $timedat; $newname = $fn; } } – Matthew May 6 '11 at 15:12 Code came out messed up, should have been an answer anyway, so I added it as an answer too. – Matthew May 6 '11 at 15:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions