SeratN Posted November 12, 2009 Share Posted November 12, 2009 Hi, I've been working on a script that downloads pictures from deviantART the last few days. Now I'm stuck and can't find any way to solve this The script will only download the pictures from the first page, it can't find the rest of the pictures... Here is an example: expandcollapse popup#include <IE.au3> $Result = _DownloadDeviantArt() MsgBox(0, "DA Downloader!", $Result) Func _DownloadDeviantArt() $HidPicForm = GUICreate("Downloading...", 400, 400) $Obj = _IECreateEmbedded() $ActiveX = GUICtrlCreateObj($Obj, 10, 10, 380, 380) $s = 1 For $i = 1 To 6 ; First page is fine, the rest is not :( _IENavigate($Obj, "http://penguina-mica.deviantart.com/gallery/#_featured--" & $i) _IELoadWait($Obj) $oImgs = _IEImgGetCollection($Obj) For $oImg In $oImgs If $oImg.src = "http://penguina-mica.deviantart.com/gallery/" And $oImg.height = 0 And $oImg.width = 0 Then ; Check for pics that are disabled. (I.E. not logged in) GUIDelete($HidPicForm) Return "Not logged in. Please logg in via IE." EndIf Next $oImgs = _IEImgGetCollection($Obj) For $oImg In $oImgs If $oImg.src = "http://penguina-mica.deviantart.com/gallery/" Or $oImg.height < 25 And $oImg.width < 25 Then ; Sort out DA original pics. $s = $s - 1 Else $Result = StringInStr($oImg.src, ".jpg") If Not $Result = 0 Then $StringSplit = StringReplace($oImg.src, "http://th", "http://fc") ; Replace preview adress with real adress. $DownloadString = StringReplace($StringSplit, "/150/i/", "/i/") ; Same ^ $Download = InetGet($DownloadString, @ScriptDir & "\Pics\Pic" & $s & ".jpg") Else $s = $s - 1 EndIf EndIf $s = $s + 1 If $s >= 25 Then ExitLoop ; I can only display 24 pics per page. Next Next GUIDelete($HidPicForm) Return "Complete." EndFunc If you try to run the code (with a folder named "Pics") you'll see that it only downloads the first 24 pics. Any help would be appreciated /SeratN Link to comment Share on other sites More sharing options...
alb19542006 Posted November 14, 2009 Share Posted November 14, 2009 (edited) Hi, SeratN I was looking for some way to get images from a website by src and came across your code I have not implemented the code for my use yet, but I repaired your code so it now downloads 115 pics from 5 pages (current count as of today) I have posted the code below with the changes commented out with ****** signs See if this helps in any way #include <IE.au3> $Result = _DownloadDeviantArt() MsgBox(0, "DA Downloader!", $Result) Func _DownloadDeviantArt() $HidPicForm = GUICreate("Downloading...", 400, 400) $Obj = _IECreateEmbedded() $ActiveX = GUICtrlCreateObj($Obj, 10, 10, 380, 380) $s = 1 For $i = 1 To 5 ; First page is fine, the rest is not _IENavigate($Obj, "http://penguina-mica.deviantart.com/gallery/#_featured--") _IELoadWait($Obj) ;************* ADDED ************** If _IELoadWait($Obj) = 0 Then _IENavigate($Obj, "http://penguina-mica.deviantart.com/gallery/#_featured--" & $i) _IELoadWait($Obj) EndIf ;************* ADDED ************** $oImgs = _IEImgGetCollection($Obj) For $oImg In $oImgs If $oImg.src = "http://penguina-mica.deviantart.com/gallery/" And $oImg.height = 0 And $oImg.width = 0 Then ; Check for pics that are disabled. (I.E. not logged in) GUIDelete($HidPicForm) Return "Not logged in. Please log in via IE." EndIf Next $oImgs = _IEImgGetCollection($Obj) For $oImg In $oImgs If $oImg.src = "http://penguina-mica.deviantart.com/gallery/" Or $oImg.height < 25 And $oImg.width < 25 Then ; Sort out DA original pics. $s = $s - 1 Else $Result = StringInStr($oImg.src, ".jpg") If Not $Result = 0 Then $StringSplit = StringReplace($oImg.src, "http://th", "http://fc") ; Replace preview adress with real address. $DownloadString = StringReplace($StringSplit, "/150/i/", "/i/") ; Same ^ $Download = InetGet($DownloadString, "C:\Pics\Pic" & $s & ".jpg") ; ******** CHANGED ******** Else $s = $s - 1 EndIf EndIf $s = $s + 1 ;If $s >= 25 Then ExitLoop ; I can only display 24 pics per page. ; ******** CHANGED ******** Next Next GUIDelete($HidPicForm) Return "Complete." EndFunc I have also attached my working script, in case the changes made are not clear to you.....IE Image Download Test.au3 P.S. - Just make sure the directory is created before trying to download...but I think you already knew that.... Regards, alb19542006 Edited November 14, 2009 by alb19542006 Link to comment Share on other sites More sharing options...
SeratN Posted November 15, 2009 Author Share Posted November 15, 2009 Was it really that simple??! Just redirect to the new page? Well, thank you very much, you've helped me a lot! Link to comment Share on other sites More sharing options...
alb19542006 Posted November 16, 2009 Share Posted November 16, 2009 Was it really that simple??!Just redirect to the new page? Well, thank you very much, you've helped me a lot!You are very welcome, glad I could be of some assistance. Link to comment Share on other sites More sharing options...
SeratN Posted November 16, 2009 Author Share Posted November 16, 2009 One note, though: You need to change If _IELoadWait($Obj) = 0 Then to If _IELoadWait($Obj) = 1 Then otherwise it will just re-download the same pics. Link to comment Share on other sites More sharing options...
alb19542006 Posted November 16, 2009 Share Posted November 16, 2009 One note, though: You need to change If _IELoadWait($Obj) = 0 Then to If _IELoadWait($Obj) = 1 Then otherwise it will just re-download the same pics. Good catch, I was wondering why pics never changed.....LOL Thank you Link to comment Share on other sites More sharing options...
pecha Posted February 3, 2011 Share Posted February 3, 2011 still download the same images, someone help? thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now