leontager Posted January 4, 2004 Posted January 4, 2004 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 Quote
Leaders dynamic_sysop Posted January 4, 2004 Leaders Posted January 4, 2004 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 Quote
leontager Posted January 4, 2004 Author Posted January 4, 2004 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) Quote
Leaders dynamic_sysop Posted January 4, 2004 Leaders Posted January 4, 2004 yes, i posted an example ( with download progress ) in the code bank;) Quote
darknuke Posted January 5, 2004 Posted January 5, 2004 (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 January 5, 2004 by darknuke Quote 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
Leaders dynamic_sysop Posted January 5, 2004 Leaders Posted January 5, 2004 you really need to run anything like the example i posted for download with progress in a new threading.thread , then it wont cause the rest of your app to lag :) Quote
darknuke Posted January 5, 2004 Posted January 5, 2004 Ah ok, Thanks! :) Quote 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
Xun Posted February 27, 2004 Posted February 27, 2004 where is the code bank? How can I find the example you posted? Quote
darknuke Posted February 27, 2004 Posted February 27, 2004 This I believe: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=81155 Quote 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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.