neal83 Posted August 1, 2008 Posted August 1, 2008 hi all this is my first post, nice to meet you all lol. i have been trying to download information from a webpage, this sounds simple enough however the data that i want is not stored in the HTML, rather it is interpreted with javascript and then printed to the browser window. At present the only way i know of to get this data is to use IE browse to the page i want, select all, copy and then write it to a text file as seen below: #include <IE.au3> $oIE = _IECreate ("http://whatever.com") $fileExit = FileOpen("EXIT.txt", 0);sends exit message to file for $loop = 1 to 10 step 1 $file = FileOpen("results.txt", 2) ;opens a file to erase previous data and replace it ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _IEAction($oIE, "selectall") ;selects all of the page _IEAction($oIE, "copy") ;copys the contents to the clipboard $sText = ClipGet() ;puts the clipboard into a variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $exitcode = FileRead($fileExit) ;reads an exit file if $exitcode = "exit" Then ExitLoop EndIf If $fileExit = -1 Then ;error check MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, $sText) ;write the page output FileClose($file) _IEAction($oIE, "refresh") $loop = $loop - 1 Next Exit the script above works all well and good but i KNOW it can be better using the COM (and way more efficiant), im just not that good at the object side of programing, could someone please (and i dont want to come across as lazy) give an example of how they would use IE to interpret the javascript code rather than going through the rigmarol of launching copying pasting etc etc. many thanks in advance neal
DaleHohm Posted August 2, 2008 Posted August 2, 2008 With the _IE functions you don't need to care that the browser content was created with Javascript in the client side. The functions access the browser in its current state (as opposed to what you see with View Source). Take a look at _IEBodyRead* functions or _IEDocReadHTML and their examples in the helpfile. 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
neal83 Posted August 2, 2008 Author Posted August 2, 2008 thanks for the reply dale: yeah ive looked at them in the help file, what i would really like to do is just download the text of the site without using IE to download all the pictures and graphics, but still use its javascript capabilities cheers neal
AdmiralAlkex Posted August 2, 2008 Posted August 2, 2008 Please excuse me if I am missing something but why do you not simply turn off images in IE? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
DaleHohm Posted August 2, 2008 Posted August 2, 2008 thanks for the reply dale:yeah ive looked at them in the help file, what i would really like to do is just download the text of the site without using IE to download all the pictures and graphics, but still use its javascript capabilitiescheers nealYou need something to interpret the Javascript... that something would be the browser. Note that if you simply don't want to have the browser appear on the screen, you can control that with the $f_visible flag in _IECreate.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
neal83 Posted August 2, 2008 Author Posted August 2, 2008 cheers gang, i didnt know that using IE would be the most efficiant method, i thought i would be taking up piles of system time by launching it, so i thought the object aproach would be better, but hey im not that experienced at oop. ps i didnt know you could turn off pictures in IE (just found out how) ha ha, thanks for the replys neal
DaleHohm Posted August 2, 2008 Posted August 2, 2008 The initial creation of the iexplore.exe process does have significant overhead. Subsequent browser instances use the same iexplore.exe process and the overhead is greatly reduced. There is no extra overhead in using the _IE functions once the broser is created. In most cases you can get what the webserver sends to the browser using INetGet, but the browser performs many functions on what is sent to it by the webser - this includes layout management and client-side processing (script interpretation and dynamic HTML). 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
bile Posted September 30, 2008 Posted September 30, 2008 The initial creation of the iexplore.exe process does have significant overhead. Subsequent browser instances use the same iexplore.exe process and the overhead is greatly reduced. There is no extra overhead in using the _IE functions once the broser is created. In most cases you can get what the webserver sends to the browser using INetGet, but the browser performs many functions on what is sent to it by the webser - this includes layout management and client-side processing (script interpretation and dynamic HTML). DaleHi, I am a new member of this forum and I have just discovered the world of Autoit.I need a script reading an IE window which is continuously updated. _IEreadbodytext works perfectly, but I need my script to read the data when they are updated.Guess I have to get some event from IE (Objevent ?) but I couldn't find clear documentation about how to do this.Could you please tell me where to search for docs?
DaleHohm Posted September 30, 2008 Posted September 30, 2008 Please don't pile on to a dormant thread -- particularly when you have a different question. This forum is ised extensively for reference and this confuses things greatly. Open a new thread. 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
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