CodyBarrett Posted January 30, 2011 Share Posted January 30, 2011 How would i go about automatically downloading all the images on a certain site? i've started this inetget example of what i want, but its not working... any ideas where i should go from here? how what i'm doing wrong? it works with this site (only one i've tested) "http://www.autoitscript.com/" whats not working:"http://www.autoitscript.com/forum/" why? :S what can i do? expandcollapse popup#include <INet.au3> #include <String.au3> Do $choice = MsgBox (4,'welcome','Would you like to download?') If $choice = 6 Then $Website = InputBox ('Website','Pick A Website To Scavenge The Downloadable Content.') If Not @error Then ;~ ConsoleWrite (GetFileName ($Website) & @CRLF) ProgressOn ('downloading','starting...') $Source = _INetGetSource($Website) ;images $array = _StringBetween ($Source,' src', '>') If IsArray ($array) Then ConsoleWrite ($Website & ' has images:' & UBound ($array) & @CRLF) For $n = 0 To UBound ($array)-1 $patharray = _StringBetween ($array[$n],'="','" ') If IsArray ($patharray) Then $percent = Round (100*($n/UBound ($array))) ProgressSet ($percent,$percent,'Downloading Content...') GetFile ($Website,$patharray[0]) EndIf Next EndIf ProgressOff () EndIf EndIf Until $choice = 7 Func GetSiteName ($Website) Local $array = StringSplit ($Website,'.') Return $array[2] EndFunc Func GetFileName ($FilePath) Local $tpath = $FilePath Do If StringInStr ($tpath,'\') Or StringInStr ($tpath,'/') Then $tpath = StringTrimLeft ($tpath,1) Else Return $tpath EndIf Until False EndFunc Func GetFile ($Website,$FilePath) Local $FileName = GetFileName ($FilePath) Local $SiteName = GetSiteName ($Website) Local $Dir = @DesktopDir & '\' & $SiteName & '\' Local $FullPath If StringLeft ($FilePath,1) == '/' Then Local $FullPath = $Website & $FilePath Else Local $FullPath = $Website & '/' & $FilePath EndIf If Not FileExists ($Dir) Then DirCreate ($Dir) EndIf Local $hDownload = InetGet($FullPath, $Dir & $FileName,16 + 2 + 1) InetClose($hDownload) EndFunc microAsinello 1 [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Zedna Posted January 30, 2011 Share Posted January 30, 2011 (edited) Example from helpfile ; ******************************************************* ; Example 2 - Create browser at AutoIt homepage, get Img collection ; and display src URL for each ; ******************************************************* #include <IE.au3> $oIE = _IECreate ("http://www.autoitscript.com/") $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) Next Edited January 30, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
CodyBarrett Posted January 30, 2011 Author Share Posted January 30, 2011 WOW! jeez thanks for that, i never knew that was even in the helpfile! However, i would like to do it in the background... instead of opening a webpage, just get the source of the page and get the images from that source directly... im kinda doing it to monitor our webpages image library remotely, and i don't want the school soccer website popping up every time i want to see if there is an extra picture from a tournament. :\ is this even possible with InetGet? if not ill be glad to use the example you gave me Zedna! [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
iamtheky Posted January 30, 2011 Share Posted January 30, 2011 or set the visible parameter to 0 on IECreate. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
CodyBarrett Posted January 31, 2011 Author Share Posted January 31, 2011 oooh! okay. i did that, and it works beautifully!!! however, now... my inetgetinfo () functions aren't working at all... whats wrong with this? inetget works, like it downloads the images and places them in their own folder, but when i check for the percentage its returning this: InetGetInfo($hDownload, 0) returns 0 InetGetInfo($hDownload, 1) returns 0 InetGetInfo($hDownload, 2) returns false InetGetInfo($hDownload, 3) returns false InetGetInfo($hDownload, 4) returns 0 InetGetInfo($hDownload, 5) returns 0 [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
iamtheky Posted January 31, 2011 Share Posted January 31, 2011 (edited) Those small pics all download to quickly. For a large amount of small items I would just do a percentage or amount of the whole, or just a running tally of how much has been copied (as is the example below). #include <IE.au3> Global $Totalbytes $oIE = _IECreate ("http://www.foxnews.com/" , 0 , 0) $oImgs = _IEImgGetCollection($oIE) $iNumImg = @extended _getstuff() tooltip ("completed " & $iNumImg & " Images with a total size of " & $Totalbytes / 1000 / 1000 & "MB." , 0 , 0) sleep (3000) exit Func _getstuff() $i = 1 For $oImg In $oImgs $Size = inetgetsize($oImg.src , 1) $ImGet = inetget($oImg.src , "C:\temppics\pic" & $i & ".jpg" , 1 , 1) $Totalbytes += $Size $i += 1 tooltip (" Item #" & $i & " downloaded " & $Totalbytes / 1000 / 1000 & "MB." , 0 , 0) Next EndFunc Edited January 31, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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