brodie28 Posted August 29, 2006 Share Posted August 29, 2006 (edited) How would I download an image from a webpage that changes each time the page is loaded? Using InetGet does not work because when it downloads the image, it has changed. I need it to download the image that is displayed when the page is loaded, the same as right clicking on it and using "save as" would. EDIT: It doesn't necessarily need to download the image, but I need to be able to imbed it into a GUI. Edited August 29, 2006 by brodie28 Link to comment Share on other sites More sharing options...
DaleHohm Posted August 29, 2006 Share Posted August 29, 2006 There have been one or two discussions of this. One is here: IE UDFs - Save image from a html page.I recall that the person eventually told me (perhaps in a PM) that they had found a workaround, but I never saw wat it was.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Confuzzled Posted August 29, 2006 Share Posted August 29, 2006 (edited) Does the IE.au3 UDF hold any hope? Parse the source and you have the file location to save with an InetGet.[edit] Dale (the author of IE.au3 - kudos to him) beat me to it! [/edit] Edited August 29, 2006 by Confuzzled Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 29, 2006 Moderators Share Posted August 29, 2006 (edited) Does the IE.au3 UDF hold any hope? Parse the source and you have the file location to save with an InetGet. [edit] Dale (the author of IE.au3 - kudos to him) beat me to it! [/edit]I'm assuming this is a random image that although it changes it always has the same URL. The only possible way I could think of doing this would be to pull the image from the browser cache. However I looked into this with the last topic Dale mentioned, but I was never able to come up with anything. Edited August 29, 2006 by big_daddy Link to comment Share on other sites More sharing options...
DaleHohm Posted August 29, 2006 Share Posted August 29, 2006 @Confuzzled ;-) Another thing to consider is that the file will exist in your browser cache, but I don't know of any interface taht allows you to find it easily. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Valuater Posted August 29, 2006 Share Posted August 29, 2006 (edited) i thought almost the same as Confuzzled inetgetsource ( to a file ) parse file ( actually hoping just the first time will show which line number in the file) then $info = filereadliine() $info2 = stringbetween( $info, "http://www.website/,,,/", ".bmp") inetget("http://www.website/,,,/" & $info2 & ".bmp,....) 8) Edited August 29, 2006 by Valuater Link to comment Share on other sites More sharing options...
DaleHohm Posted August 29, 2006 Share Posted August 29, 2006 @Val I think the trouble is that the image that they want to get changes each time they connect to the page -- and they want the one that is displayed at the moment. InetGet initiates a new connection to the server each time (and the image changes even though the URL is the same). Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Confuzzled Posted August 29, 2006 Share Posted August 29, 2006 brodie28: What is the webpage you are trying so desperately to suck images from?Maybe turn this problem over and look at it from the other end - instead of getting your browser to display the webpage and then realise you have missed the image of a lifetime, why not get AutoIT to fetch it first and then display it to see if that is the one you want and discard it if it is not? Alternatively, you could always embed the image inside a local web page you have generated from AutoIT and refresh the contents using the functions in the IE.au3 UDF. Link to comment Share on other sites More sharing options...
Valuater Posted August 29, 2006 Share Posted August 29, 2006 (edited) @ValI think the trouble is that the image that they want to get changes each time they connect to the page -- and they want the one that is displayed at the moment. InetGet initiates a new connection to the server each time (and the image changes even though the URL is the same).Dale@Dale..I thought you would understand how this could work. Yes the initial URL does not change ( hopefully ) and that is why i would use inetgetsource from the constant URLif the "pic" changes, hopefully it would remain on the same line number in downloaded file each timethen you could get a string between the "http//www." and the ".bmp" ( if it is a bmp )then use inetget "http//www." & $the_string_between & ".bmp"i have done it.... it could work8) Edited August 29, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted August 29, 2006 Share Posted August 29, 2006 (edited) Example.... if a number changes ; Get the Latest Beta ; Author - Valuater #include <INet.au3> $NBeta = _INetGetSource('http://www.autoitscript.com/autoit3/files/beta/autoit/') For $x = 500 to 104 Step -1 If StringInStr( $NBeta, "autoit-v3.1.1."& $x & "-beta-Setup.exe") Then $NBeta = "autoit-v3.1.1."& $x & "-beta-Setup.exe" ExitLoop EndIf If $x <= 105 Then MsgBox(262208, "Beta Error", "No File Found. ", 5) Return EndIf Next MsgBox(0,'',$NBeta) ; use InetGet() there is anothere in the examples for Welcome to Autoit 1-2-3... i will get that one too 8) Edited August 29, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted August 29, 2006 Share Posted August 29, 2006 here it is expandcollapse popup; demonstration to find chracters that change between to standard points ; or just find a string #include <IE.au3> #Region --- IE-Builder generated code Start --- $oIE = _IECreate () ;------------- User input -------------- _IENavigate ($oIE, "http://www.autoitscript.com/") ; web address $Find = "LZ" ; my info shows after this line... or just find this line $Before = "comp" ; my info shows before this line... or set as "" ; ------------ End User input ------------- Sleep(1000) $body = _IEBodyReadHTML ($oIE) $sloc = @TempDir & "\stest.txt" FileDelete($sloc) FileWrite($sloc, $body) $sfile = FileOpen($sloc, 0) $num = 0 While 2 $num = $num + 1 $sline = FileReadLine($sfile, $num) If @error Then MsgBox(262208, "Fail", "The string was NOT found ") FileClose($sfile) Exit EndIf If StringInStr($sline, $Find) Then MsgBox(64, "Success", "The string " & $Find & " was found " & @CRLF & " on line # " & $num, 5) If $Before = "" Then ExitLoop $Found = stringbetween($sline, $Find, $Before) MsgBox(64, "Found", "The string is " & $Found & " ", 5) ExitLoop EndIf WEnd Func stringbetween($str, $start, $end) $pos = StringInStr($str, $start) If Not @error Then $str = StringTrimLeft($str, $pos + StringLen($start) - 1) $pos = StringInStr($str, $end) If Not @error Then $str = StringTrimRight($str, StringLen($str) - $pos + 1) Return $str EndIf EndIf EndFunc ;==>stringbetween #EndRegion --- IE-Builder generated code End --- 8) Link to comment Share on other sites More sharing options...
Valuater Posted August 29, 2006 Share Posted August 29, 2006 @ValI think the trouble is that the image that they want to get changes each time they connect to the page -- and they want the one that is displayed at the moment. InetGet initiates a new connection to the server each time (and the image changes even though the URL is the same).Dalejust noticed this....InetGet initiates a new connection to the server each timemaybe your right... but the last pic should still work.... it still has a valid URL ( hopefully )8) Link to comment Share on other sites More sharing options...
Valik Posted August 29, 2006 Share Posted August 29, 2006 Presumably one could invoke the "Save Page" feature either through the object model if such a method exists or via basic Window automation. That would save both the page and all images. Then it would be possible to find the file on disk. Link to comment Share on other sites More sharing options...
brodie28 Posted August 29, 2006 Author Share Posted August 29, 2006 If there was a way to download the entire webpage automaticly (at the moment all that is possible is opening a save as dialogue box) then maybe I could search through the images it saved.... Do you think saving images through the object model will ever be implemented in IE Dale? Link to comment Share on other sites More sharing options...
Confuzzled Posted September 2, 2006 Share Posted September 2, 2006 Did you actually try the suggestions? In InetGet you have the option to fetch the browser cached version, which I think is what you are wanting.Even a 'save as' will have to go out and fetch the file. Link to comment Share on other sites More sharing options...
DaleHohm Posted September 2, 2006 Share Posted September 2, 2006 (edited) If there was a way to download the entire webpage automaticly (at the moment all that is possible is opening a save as dialogue box) then maybe I could search through the images it saved....Do you think saving images through the object model will ever be implemented in IE Dale?No, not through the browser object model anyway. The fact is that you can invoke the Save As function using the browser object model and there is actually a noPrompt option documented that would allow you to fully script the operation, but the functionality was removed for security reasons -- so it always puts up a save as dialog.So, you can do this with windows automation or a combination of COM and windows automation.Regarding InetGet... if you haven't already I think you should do some testing with it. Pulling from cache is its default action, so it may work. The example I placed in the snippet database would help you figure out the url of the image and invoke InetGet on it -- I don't know what happens if the page specifies CACHE-CONTROL:NO-CACHE however. Please post your testing results.DaleEdit: typos ans snippet url Edited September 2, 2006 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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