joshiieeii Posted July 26, 2006 Share Posted July 26, 2006 (edited) Hi guys, I have a situation where I have a Javascript web page that has several bits of data seperated by <tr> tags. I would like to redisplay only certain bits of the website based on a keyword/phrase. Also, updating the data every so often (lets say 30 seconds), so that the redisplay is correctly displaying the search from the original page.(I also need to maintain the javascript environment) *Edit: also wanted to mention that this page is an *.asp, don't know if that helps, but more info is betta*I have tried the tried and true search function, no luck. I have tried several of the IE functions, including:_IETagNameAllGetCollection_IETableGetCollection_IETableWriteToArrayThese are not returning any values other than 0 or the occasional garbled text.Any ideas?So far, I am embedding the page in an AutoIT GUI and then hiding the webpage.Here is some sample code, had to butcher it a bit and remove the javascript....expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () $parent = GUICreate("Test", 880, 780, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS) GUISetState ( @SW_HIDE, $parent) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 860, 560) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 620, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 620, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 620, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 620, 100, 30) _IENavigate ($oIE, "http://Test.asp") _IELoadWait ($oIE) ControlClick ( "Test", "", 1) Send("{DOWN}") Send ("{ENTER}") sleep (3000) GUISetState ( @SW_SHOW, $parent) $oTable = _IETableGetCollection ($oIE) $iNumTables = @extended MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, "http://www.autoitscript.com") Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction ($oIE, "stop") EndSelect WEnd GUIDelete() Exitexpandcollapse popup<html> <head> <title>Test Page</title> </head> <body> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="1"> <tr> <td nowrap class="gridHeader">Test1</td> <td nowrap class="gridHeader">Test2</td> <td nowrap class="gridHeader">Test3</td> <td nowrap class="gridHeader">Test4</td> <td nowrap class="gridHeader">Test5</td> <td nowrap class="gridHeader">Test6</td> <td nowrap class="gridHeader">Test7</td> <td nowrap class="gridHeader">Test8</td> </tr> <tr> <td valign="top" class="griditem2" nowrap><p align="left"> <a href="/Test/cm/displayTest/test.asp?id=123458&selGroup=3">123458</a></td> <td valign="top" class="griditem2" nowrap><p align="left">7/21/2006 2:12:35 PM</td> <td valign="top" class="griditem2" nowrap><p align="left">Test</td> <td valign="top" class="griditem2" nowrap><p align="left"><SPAN Class="smallerror">Overdue</SPAN></td> <td valign="top" class="griditem2" nowrap><p align="left">Normal</td> <td valign="top" class="griditem2" nowrap><p align="left">Testing</td> <td valign="top" class="griditem2" nowrap><p align="left">R. Test</td> <td valign="top" class="griditem2" nowrap><p align="left"></td> </tr> <tr> <td valign="top" class="griditem1" nowrap><p align="left"> <a href="/Test/cm/displayTest/test.asp?id=123457&selGroup=3">123457</a><SPAN Class="smallerror"> U/A</SPAN></td> <td valign="top" class="griditem1" nowrap><p align="left">7/26/2006 8:46:54 AM</td> <td valign="top" class="griditem1" nowrap><p align="left">Test</td> <td valign="top" class="griditem1" nowrap><p align="left">Not Started</td> <td valign="top" class="griditem1" nowrap><p align="left">Urgent</td> <td valign="top" class="griditem1" nowrap><p align="left">Testing</td> <td valign="top" class="griditem1" nowrap><p align="left">j.Bloe</td> <td valign="top" class="griditem1" nowrap><p align="left"></td> </tr> <tr> <td valign="top" class="griditem2" nowrap><p align="left"> <a href="/Test/cm/displayTest/test.asp?id=123456&selGroup=3">123456</a><SPAN Class="smallerror"> U/A</SPAN></td> <td valign="top" class="griditem2" nowrap><p align="left">7/26/2006 8:49:46 AM</td> <td valign="top" class="griditem2" nowrap><p align="left">Test</td> <td valign="top" class="griditem2" nowrap><p align="left">Not Started</td> <td valign="top" class="griditem2" nowrap><p align="left">Normal</td> <td valign="top" class="griditem2" nowrap><p align="left">Testing</td> <td valign="top" class="griditem2" nowrap><p align="left">j.smith</td> <td valign="top" class="griditem2" nowrap><p align="left"></td> </tr> </table> </td> </tr> </table> </center> </form> </body> </html> Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
Paulie Posted July 26, 2006 Share Posted July 26, 2006 Wanna post you're autoit code? as the HTML of the web page you want to display is almost totally irrelevant Link to comment Share on other sites More sharing options...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 (edited) Its not so much that I can't get it working, but more so that I can't even find anything that can pull the results I am looking for. So it's more of a "does anyone know a way" vs. "I can't work the details out". *Edit: In the above code I get 0 as the result. Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
DaleHohm Posted July 26, 2006 Share Posted July 26, 2006 If that is your source and you see no tables, I'm going to guess taht it is acually in a frame. Try ConsoleWrite(_IEDocReadHTML($oIE) & @CR) 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...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 (edited) If that is your source and you see no tables, I'm going to guess taht it is acually in a frame. Try ConsoleWrite(_IEDocReadHTML($oIE) & @CR) DaleActually it's funny you say that, I was just now going through some more of the examples in the IE.au3, and indeed it did say there were 2 frames *Edit: Results: <HTML><HEAD></HEAD><FRAMESET border=0 frameSpacing=0 rows=100%,* frameBorder=0><FRAME name=DisplayTestsrc="/Test/CM/ListTests/Test.asp"><FRAME name=TestFunctions src="" scrolling=no></FRAMESET></HTML> Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
DaleHohm Posted July 26, 2006 Share Posted July 26, 2006 So look at _IEFrameGetObjByName() 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...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 So look at _IEFrameGetObjByName()DaleStupid question, how do you get the frame name? Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
DaleHohm Posted July 26, 2006 Share Posted July 26, 2006 Look in the HTML code you showed in Post 5. 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...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 Look in the HTML code you showed in Post 5. Dale wow.....Can't believe I missed that....well...I did that and it i get some weird code back when I console write the results.... ù Still not able to get any of the data pulled from the site....=( Hmm....playing with the code some more to see if I can get some results. Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
slipperylobster Posted July 26, 2006 Share Posted July 26, 2006 ok.. I am not as smart as most of the guys here. I do what I can with the limited amount of brain cells left after ar hard day of drinking.. Here is what I did to get random jokes out of a webpage. I just know it aint pretty..but it works! Use beta for voice or delete two lines referencing voice. Notice, I pull out the joke string and get rid of most of the exterraneous b/s. But I have it read from a file. use your own $filedir. while 1 $filedir = "C:\AA TASKBAR SHORTCUTS\Desk\Hold Basket\Joke.txt" $last = 0 $end = 0 $linenumb = 0 $joke = "" $line = "" $file="" Local $o_speech = ObjCreate ("SAPI.SpVoice") go() wend Func go();;;;;;;;;;;;;;;;;; $file = FileOpen($filedir, 0) $o_speech.Speak("I Have a good joke for you") $rnd = Random(1, 11146, 1) $rssfeed = "http://jokes.comedycentral.com/random_joke.aspx?joke_id=" & $rnd InetGet($rssfeed, $filedir,1,0) For $linenumb = 464 To 500 Step 1 $line = FileReadLine($file, $linenumb) If $linenumb = 467 Then StringTrimLeft($line, 100) $line=stringreplace($line,"<p>","") $line=stringreplace($line,"<br>","") $joke = $joke & $line $last = StringInStr($line, "</div>") If $last > 0 Then finish() Next endfunc Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 26, 2006 Moderators Share Posted July 26, 2006 wow.....Can't believe I missed that....well...I did that and it i get some weird code back when I console write the results.... ù Still not able to get any of the data pulled from the site....=( Hmm....playing with the code some more to see if I can get some results.What exactly are you wanting to pull from the site? p.s. The code you posted looks like an object variable, you can need to specify what data you want from it first. Link to comment Share on other sites More sharing options...
slipperylobster Posted July 26, 2006 Share Posted July 26, 2006 I screwed up... Here is the full code... while 1 $filedir = "C:\AA TASKBAR SHORTCUTS\Desk\Hold Basket\Joke.txt" $last = 0 $end = 0 $linenumb = 0 $joke = "" $line = "" $file="" Local $o_speech = ObjCreate ("SAPI.SpVoice") go() wend Func go();;;;;;;;;;;;;;;;;; $file = FileOpen($filedir, 0) $o_speech.Speak("I Have a good joke for you") $rnd = Random(1, 11146, 1) $rssfeed = "http://jokes.comedycentral.com/random_joke.aspx?joke_id=" & $rnd InetGet($rssfeed, $filedir,1,0) For $linenumb = 464 To 500 Step 1 $line = FileReadLine($file, $linenumb) If $linenumb = 467 Then StringTrimLeft($line, 100) $line=stringreplace($line,"<p>","") $line=stringreplace($line,"<br>","") $joke = $joke & $line $last = StringInStr($line, "</div>") If $last > 0 Then finish() Next endfunc Func finish() $file=fileclose($filedir) $joke=stringtrimright($joke,6) SoundPlay("D:\My Music\Sound Effects\People\kids giggle.wav", 1) splashtextOn("Jokes (Press (CntrlAltShift E) to Exit",$joke) $o_speech.Speak($joke) SoundPlay("D:\My Music\Sound Effects\People\kids laugh.wav", 1) splashoff() sleep(100) $ans=msgbox(1,"Joke Machine","Want Another?") if $ans=2 then exit EndFunc Link to comment Share on other sites More sharing options...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 (edited) I appreciate your help, althought that is very cool and interesting, doesn't really apply to my particular situation. I am dealing with Frames and a tabled structure. In retrospect that does do technically what my topic states. Good job! Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 (edited) What exactly are you wanting to pull from the site? p.s. The code you posted looks like an object variable, you can need to specify what data you want from it first.To answer your question, I am just trying to display the sections of code that begin with <tr> and have the words not started in them. I need to specify what data? where do I do that....the code does not have an example of that: _IEFrameGetObjByName ( ByRef $o_object, $s_name ) Parameters $o_object Object variable of an InternetExplorer.Application, Window or Frame object $s_name Name of the Frame you wish to match Return Value Success: Returns an object variable pointing to the Window object in a Frame, @EXTENDED = Frame count Failure: Returns 0 and sets @ERROR @Error: 0 ($_IEStatus_Success) = No Error 3 ($_IEStatus_InvalidDataType) = Invalid Data Type 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type 7 ($_IEStatus_NoMatch) = No Match @Extended: Contains invalid parameter number so I have the $object...= $oIE and the $s_name = "TestFunctions" Where do I specify what data I want to pull? *Edit:Does the frame act like a container of sorts, so once I have the container's name(resulting from the _IEFrameGetObjByName), what do I query with? Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
joshiieeii Posted July 26, 2006 Author Share Posted July 26, 2006 (edited) By Jove I found it!! had to include this code... $oFrame = _IEFrameGetObjByName ($oIE, "TestFunctions") $sHTML = _IEBodyReadHTML ($oFrame) ConsoleWrite($sHTML & @CR) **Edit: Hmm..now all I have to do is find a way to trim out the stuff I don't want and redisplay it. I wonder what would be the best way to do that...array? I will mess with it tomorrow....later guys... Edited July 26, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 26, 2006 Moderators Share Posted July 26, 2006 This should get you started: $oFrame = _IEFrameGetObjByName ($oIE, "TestFunctions") $oTags = _IETagNameGetCollection($oFrame, "td") For $oTag In $oTags $sText = $td.innerText If $sText = "Not Started" Then ;;; not sure what you are wanting to do from here EndIf Next Link to comment Share on other sites More sharing options...
DaleHohm Posted July 26, 2006 Share Posted July 26, 2006 By Jove I found it!! had to include this code... $oFrame = _IEFrameGetObjByName ($oIE, "TestFunctions") $sHTML = _IEBodyReadHTML ($oFrame) ConsoleWrite($sHTML & @CR) **Edit: Hmm..now all I have to do is find a way to trim out the stuff I don't want and redisplay it. I wonder what would be the best way to do that...array? I will mess with it tomorrow....later guys...See the _IETable* functions... 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...
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