psychoblast Posted March 26, 2012 Share Posted March 26, 2012 This forum was of no help so far so Ill give it one last chance.... How can I download a specific image from a webpage. I have a code that will show the number of images present on the webpage and all of their .scr However, how do i go about downloading an indexed image. I tried creating an array but that was of no luck. $oImgs = _IEImgGetCollection($oIE) $iNumImg = @extended MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page") For $oImg In $oImgs MsgBox(0, "Img Info " , "src=" & $oImg.src) InetGet ("$oImg", @DesktopDir) Next Link to comment Share on other sites More sharing options...
Damein Posted March 26, 2012 Share Posted March 26, 2012 Would you mind sending me the website its located at and the image file you are trying to get? If you are un-willing to do that then here is a snippet of my code I currently use to take the images from Weather.com. If its confusing then let me know. expandcollapse popupFunc _GetOverViewImages() $Url = 'http://www.weather.com/weather/today/' & $City[1] & '+' & $State[1] & '+' & $Zipcode Global $sSource = BinaryToString(InetRead($Url,1)) $Image1 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 1.*-->", 1) $Image2 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 2.*-->", 1) $Image3 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 3.*-->", 1) $Image4 = StringRegExp($sSource, "(?i)<imgssrc=.+(http.+.png).*column 4.*-->", 1) For $i = 1 To 4 If $i = 1 Then $OverViewImage[1] = $Image1[0] ElseIf $i = 2 Then $OverViewImage[2] = $Image2[0] ElseIf $i = 3 Then $OverViewImage[3] = $Image3[0] ElseIf $i = 4 Then $OverViewImage[4] = $Image4[0] EndIf Next For $i = 1 To 4 If $i = 1 Then FileDelete(@ScriptDir & "ImagesImage1.png") $RightNowImage = InetGet($OverViewImage[1], @ScriptDir & "ImagesImage1.png",1) EndIf If $i = 2 Then FileDelete(@ScriptDir & "ImagesImage2.png") $TodayImage = InetGet($OverViewImage[2], @ScriptDir & "ImagesImage2.png",1) EndIf If $i = 3 Then FileDelete(@ScriptDir & "ImagesImage3.png") $TonightImage = InetGet($OverViewImage[3], @ScriptDir & "ImagesImage3.png",1) EndIf If $i = 4 Then FileDelete(@ScriptDir & "ImagesImage4.png") $TomorrowImage = InetGet($OverViewImage[4], @ScriptDir & "ImagesImage4.png",1) EndIf Next EndFunc Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
psychoblast Posted March 26, 2012 Author Share Posted March 26, 2012 Ok im am using a random video on youtube. When you comment too many times you get a captcha image. I am trying to download that. Here is my full code. Not sure if its really legal in this forum that is why I did not include it. #include<IE.au3> ;_IEErrorHandlerRegister() ;_IELoadWaitTimeout(5000) $oIE=_IECreate("http://www.youtube.com/watch?v=JjmeSwPig_8",0,1,1) _IELoadWait($oIE) $oForm=_IEGetObjByName($oIE,"comment") _IEAction($oForm, "focus") ;_IEFormSubmit($oForm) ;$oSubmit=_IEGetObjByName($oIE,"add_comment_button") _IEFormElementSetValue($oForm,"Thanks") $oButtons = _IETagNameGetCollection ($oIE, "button") For $oButton In $oButtons If $oButton.type = "submit" Then _IEAction ($oButton, "click") Next $oImgs = _IEImgGetCollection($oIE) $iNumImg = @extended MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page") For $oImg In $oImgs MsgBox(0, "Img Info " , "src=" & $oImg.src) InetGet ("$oImg", @DesktopDir) Next Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2012 Moderators Share Posted March 26, 2012 (edited) psychoblast,Not sure if its really legal in this forumIt is not - do not post asking about CAPTCHAs on this forum again. M23Edit:This forum was of no help so far so Ill give it one last chanceAnd if this really was the last chance, we will not miss you! Edited March 26, 2012 by Melba23 Noticed the first line of the first post Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts