Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - download all images from a web page

Reply
 
Old 08-14-2009   #1 (permalink)


Vista Home Premium 32bit
 
 

download all images from a web page

Hallo guys.
I use this code to download single images from a serie of urls

$wc = New-Object System.Net.WebClient
$path = "my_path\my_folder\"
gc "my_path\urls_list.txt" | % {
$file = ([system.IO.Path]::getfilename($_))
$wc.DownloadFile($_,($path+$file))
}

but I'd like to know if it's possible to download all the images from a web page. Thanks in advance.

My System SpecsSystem Spec
Old 08-15-2009   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: download all images from a web page

You would simply need to parse the downloaded file and look for images in
it. Like an IMG SRC flag, then download all the matches.

I'm sorry, I don't have time this morning to check this out, but maybe
someone else will come along.

Marco

"sardinian_guy" <guest@xxxxxx-email.com> wrote in message
news:1ca0249509651afa3d05ba75b4a235bc@xxxxxx-gateway.com...
Quote:

>
> Hallo guys.
> I use this code to download single images from a serie of urls
>
> $wc = New-Object System.Net.WebClient
> $path = "my_path\my_folder\"
> gc "my_path\urls_list.txt" | % {
> $file = ([system.IO.Path]::getfilename($_))
> $wc.DownloadFile($_,($path+$file))
> }
>
> but I'd like to know if it's possible to download all the images from a
> web page. Thanks in advance.
>
>
> --
> sardinian_guy
My System SpecsSystem Spec
Old 08-16-2009   #3 (permalink)
Shay Levy [MVP]


 
 

Re: download all images from a web page


$ie = new-object -com internetexplorer.application
$ie.visible=$true
$ie.Navigate("http://msn.com")
while($ie.busy) {start-sleep -milli 250}

$wb = New-Object System.Net.WebClient

$ie.Document.getElementsByTagName("IMG") | foreach {
$wb.DownloadFile($_.src, ("$path\"+[io.path]::GetFileName($_.src)))
}

$wb.dispose()
$ie.quit()




---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



s> Hallo guys. I use this code to download single images from a serie of
s> urls
s>
s> $wc = New-Object System.Net.WebClient
s> $path = "my_path\my_folder\"
s> gc "my_path\urls_list.txt" | % {
s> $file = ([system.IO.Path]::getfilename($_))
s> $wc.DownloadFile($_,($path+$file))
s> }
s> but I'd like to know if it's possible to download all the images from
s> a web page. Thanks in advance.
s>


My System SpecsSystem Spec
Old 08-18-2009   #4 (permalink)
OldDog


 
 

Re: download all images from a web page

On Aug 16, 3:01*pm, Shay Levy [MVP] <n...@xxxxxx> wrote:
Quote:

> $ie = new-object -com internetexplorer.application
> $ie.visible=$true
> $ie.Navigate("http://msn.com")
> while($ie.busy) {start-sleep -milli 250}
>
> $wb = New-Object System.Net.WebClient
>
> $ie.Document.getElementsByTagName("IMG") | foreach {
> * *$wb.DownloadFile($_.src, ("$path\"+[io.path]::GetFileName($_.src)))
>
> }
>
> $wb.dispose()
> $ie.quit()
>
> ---
> Shay Levy
> Windows PowerShell MVPhttp://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar:http://tinyurl.com/PSToolbar
>
> s> Hallo guys. I use this code to download single images from a serie of
> s> urls
> s>
> s> $wc = New-Object System.Net.WebClient
> s> $path = "my_path\my_folder\"
> s> gc "my_path\urls_list.txt" | % {
> s> $file = ([system.IO.Path]::getfilename($_))
> s> $wc.DownloadFile($_,($path+$file))
> s> }
> s> but I'd like to know if it's possible to download all the images from
> s> a web page. Thanks in advance.
> s>
I get this error:

ERROR: You cannot call a method on a null-valued expression.
ERROR: At line:20 char:34
ERROR: + $ie.Document.getElementsByTagName( <<<< "IMG") | foreach {

Not at all sure what it means.

OldDog
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
 Why have images on any web·page, why not Google·Groups too ? Live Mail
Windows 7 RC download page goes up early, coming in May Vista News
Page-up gets stuck when attempting to scroll over images Live Mail
need help quick!! i cant download images, bar code, in Email, Browsers & Mail
increasing time to allow web sites to download page Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46