Things i'll fix:
- The blacklist is hardcoded and not in an external file.
- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)
- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it.
#include #include #include #include #include Global $HorizontalPlacement = 1 Global $HorizontalSpacing = 10 Global $ArrayImages[1] Global $ArrayDownload[1] Global $DropdownBlacklistText = "Select blacklist" Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\" ;~ <a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/</a> $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 120) ;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $InputLink = GUICtrlCreateInput("<a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/"</a>, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80) $ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80) _WriteSWBlacklist() _BlacklistDropdownUpdater() GUISetState(@SW_SHOW) Func _WriteSWBlacklist() Global $SWBlacklist[1] Local $ArrayCounter = 0 _ArrayAdd($SWBlacklist, "StanceWorks.com") _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a>) $ArrayCounter += 1 _ArrayInsert($SWBlacklist, 0, $ArrayCounter) _ArrayDelete($SWBlacklist, 1) ;~ _ArrayDisplay($SWBlacklist) ;~ MsgBox("","", $ArrayCounter) EndFunc ;==>_WriteSWBlacklist Func _BlacklistDropdownUpdater() _GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1]) EndFunc ;==>_BlacklistDropdownUpdater Func _BlacklistUpdater() Global $ArrayBlacklist;[1] ;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist)) Select Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com" $ArrayBlacklist = $SWBlacklist EndSelect ;~ _ArrayDisplay($ArrayBlacklist) EndFunc ;==>_BlacklistUpdater Func _ImageFilter($SiteLink) _BlacklistUpdater() Local $oIE = _IECreate($SiteLink) _IELoadWait($oIE) Local $sTags = _IETagNameGetCollection($oIE, "img") Local $ImageCount = @extended Local $iCounter1 Local $iCounter2 Local $ArrayDownloadCounter = 0 ;~ MsgBox("", "", $ImageCount) $ArrayImages[0] = $ImageCount For $tag In $sTags ;~ MsgBox("", "", $tag.src) _ArrayAdd($ArrayImages, $tag.src) Next ;~ _ArrayDisplay($ArrayImages) ;~ _ArrayDisplay($ArrayBlacklist) ;~ _ArrayDisplay($ArrayDownload) For $iCounter1 = 1 To $ArrayImages[0] Step 1 ;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF) For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1 ;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF) If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then ExitLoop ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then ;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF) _ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1]) $ArrayDownloadCounter += 1 EndIf Next Next ProcessClose("iexplore.exe") _ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter) _ArrayDelete($ArrayDownload, 1) ;~ _ArrayDisplay($ArrayDownload) _ImageDownloader() EndFunc ;==>_ImageFilter Func _ImageDownloader() Local $DLCounter Local $iDeleteCounter ;~ MsgBox("", "", $SaveFolderLocation) If Not FileExists($SaveFolderLocation) Then DirCreate($SaveFolderLocation) If @error = 0 Then ConsoleWrite("!Error creating directory" & @CRLF) Else ConsoleWrite("+No error creating directory" & @CRLF) EndIf EndIf For $DLCounter = 1 To $ArrayDownload[0] Step 1 $DownloadName = _Stringifier($ArrayDownload[$DLCounter]) InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName) ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF) ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF) ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF) Next ;~ _ArrayDisplay($ArrayDownload) For $iDeleteCounter = $ArrayDownload[0] to 0 step -1 _ArrayDelete($ArrayDownload,$iDeleteCounter) Next Global $ArrayDownload[1] ;~ _ArrayDisplay($ArrayDownload) MsgBox("", "", "Download completed!") GUICtrlSetData($InputLink,"Link") $SaveFolderLocation = "XXX" EndFunc ;==>_ImageDownloader Func _Stringifier($Link) Local $Counter Local $Feedback Local $ArraySize Local $Array[2] Local $CutValue Local $String ;~ $Link = "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a> $Pattern = "(/*.)?" $Array = StringRegExp($Link,$Pattern,3) ;~ _ArrayDisplay($Array) $ArraySize = (UBound($Array)-1) ;~ MsgBox("","",$ArraySize ) For $Counter = $ArraySize to 0 step -1 $Feedback = StringInStr($Array[$Counter],"/") ;~ ConsoleWrite("!" & $Counter & "-" & $Array[$Counter] & ": " & $Feedback & @CRLF) If $Feedback = 1 then ExitLoop Next ;~ MsgBox("","",$Feedback) ;~ MsgBox("","",$Counter) $CutValue = $ArraySize - $Counter ;~ MsgBox("","",$CutValue) $String = StringRight($Link,$CutValue) ;~ MsgBox("","",$String) Return $String EndFunc ;~ <a href='http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/</a> While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ButtonBrowse If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then MsgBox("", "", "Please select a blacklist!") Else $SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", -1, "Images") & "\") MsgBox("", "", $SaveFolderLocation) _BlacklistUpdater() EndIf Case $ButtonDownload If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then MsgBox("", "", "Please select a blacklist!") ElseIf $SaveFolderLocation = "XXX" Then MsgBox("", "", "Please select a save folder" & @CRLF & "(Click browse)") Else _ImageFilter(GUICtrlRead($InputLink)) EndIf EndSwitch WEnd





