Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, how can I save all the images on a webpage? Similarly to when you do it manually and IE creates the HTML file and a seperate folder for all the images.

 

I think it will have something to do with this

 

Dim htImg As mshtml.HTMLImg

Dim obDC As mshtml.HTMLDocument

Dim ITEM As Object

Dim obIE As SHDocVw.InternetExplorer

 

For Each htImg In obDC.images.item

'somehow save it

Next

 

obviously this doesnt work :-)

but can someone please tell me how to make it work

  • Leaders
Posted

like this maybe .....

   Private doc As mshtml.HTMLDocument

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       AxWebBrowser1.Navigate("http://google.com")
   End Sub

   Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
       doc = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocument)
   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       If Not doc Is Nothing Then
           Dim img As mshtml.HTMLImg

           For Each img In doc.images
               If img.href <> "" Then
                   Dim wc As New Net.WebClient()
                   wc.DownloadFile(img.href, "C:\" & img.href.Split("/")(img.href.Split("/").GetUpperBound(0)))
               End If
           Next
       End If
   End Sub

Posted

wow thank you very much

 

you can also use this

 

Dim myRequest As WebRequest = WebRequest.Create(address)

Dim bmp As Bitmap = Bitmap.FromStream(myRequest.GetResponse().GetResponseStream())

bmp.save(path)

Posted (edited)

I altered your example a little (only added url parsing for file saving, progress bar fix, and added a percentage label), and whenever I use it or the original, my computer begins to lag badly and the example acts a like a non responsive program, but I can still see the progress bar go up. However when it's done, it all goes back to normal. Is there any way to prevent this? I can download it all in one chunk, but then there's no progress bar :( (unless I checked the file size of the file while it was still being downloaded, but I'm guessing it would produce the same laggy results).

 

-> I just tried using DownloadFile() all by itself with no size checks, etc and it still lags and acts non responsive... why? I thought that would go faster... :(

Edited by darknuke

This is only a test of the emergency broadcast system

This is a product of hysterical mass confusion

A ship of fools adrift on the sea of our pollution

Rudderless and powerless on the sea of our delusion

pennywise - this is only a test

Posted
Ah ok, Thanks! :)

This is only a test of the emergency broadcast system

This is a product of hysterical mass confusion

A ship of fools adrift on the sea of our pollution

Rudderless and powerless on the sea of our delusion

pennywise - this is only a test

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...