iloveautoitv3 Posted March 24, 2009 Share Posted March 24, 2009 Hello,i have a BIG problem.What i want to do is:1. Surfing to a Website with an iFrame. Wait until the page is loaded.2. Now i try to get the Source Code from the ready-loaded-iFrame with the command _IEBodyReadHTML($iFrame), but it fails. The error comes also with other _IE commands, like _IEPropertyGet($iFrame, "locationurl").Here is my script:#include <IE.au3>#include <File.au3>#include <String.au3>;;;create$oIE = _IECreate ("http://home.arcor.de/qxggnxan/a-site-with-an-iframe.htm")_IELoadWait ($oIE);;;iFrame$iFrame0001 = _IEFrameGetObjByName ($oIE, "0001")$sHTML = _IEBodyReadHTML ($iFrame0001)msgbox(1,"the source code",$sHTML)Any one can help please? Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2009 Share Posted March 24, 2009 Hello, i have a BIG problem. What i want to do is: 1. Surfing to a Website with an iFrame. Wait until the page is loaded. 2. Now i try to get the Source Code from the ready-loaded-iFrame with the command _IEBodyReadHTML($iFrame), but it fails. The error comes also with other _IE commands, like _IEPropertyGet($iFrame, "locationurl"). Here is my script: #include <IE.au3> #include <File.au3> #include <String.au3> ;;;create $oIE = _IECreate ("http://home.arcor.de/qxggnxan/a-site-with-an-iframe.htm") _IELoadWait ($oIE) ;;;iFrame $iFrame0001 = _IEFrameGetObjByName ($oIE, "0001") $sHTML = _IEBodyReadHTML ($iFrame0001) msgbox(1,"the source code",$sHTML) Any one can help please? You don't do any error checking to see if it got the iFrame correctly before trying to read the body. Put _IEErrorHandlerRegister() at the top of your script, and run it from SciTE so you can see the debug output to the console. Test for @error after _IEFrameGetObjByName() so you can catch problems finding the iFrame before trying to use it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DaleHohm Posted March 24, 2009 Share Posted March 24, 2009 Also, _IEGetObjByName gets you a reference to your iFrame as a tag, not as a window. You need to use _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...
iloveautoitv3 Posted March 24, 2009 Author Share Posted March 24, 2009 (edited) Thanks for your answers.I cant find a way to read the htmlcode from the iframe.It just shows me nothing Edited March 24, 2009 by iloveautoitv3 Link to comment Share on other sites More sharing options...
Authenticity Posted March 24, 2009 Share Posted March 24, 2009 Can you post the html of the document? Link to comment Share on other sites More sharing options...
iloveautoitv3 Posted March 24, 2009 Author Share Posted March 24, 2009 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><iframe src="http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=text&x=7&y=18" width="820" height="220" name="0001"></iframe></body></html> Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2009 Share Posted March 24, 2009 (edited) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <iframe src="http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=text&x=7&y=18" width="820" height="220" name="0001"></iframe> </body> </html> That's a cross-site scripting situation, because the parent is in www.w3.org space and the iFrame is in www.amazon.com space. If you had added the error handler and run it in SciTE as I recommended before, you would probably see "Access Denied" or something similar. You can extract the URL (the amazon one) from the iFrame tag and then open it in its own instance of IE, then work with that. Edit: Maybe not... I was being dense, and the "www.w3.org" is not the parent document but a standardized header, of course. This could still be a case of cross-site issues if the parent is other than www.amazon.com, but it has nothing to do with the www.w3.org part. Edited March 24, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iloveautoitv3 Posted March 24, 2009 Author Share Posted March 24, 2009 Thanks, but the htmlcode is now without www.w3.org.<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><iframe src="http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=text&x=7&y=18" width="820" height="220" name="0001"></iframe></body></html>i runned the script again, but the only thing i get is this empty source-code-msgbox:You can extract the URL (the amazon one) from the iFrame tag and then open it in its own instance of IE, then work with that.Whats faster & better? Open 100 IE's or run 100 iFrames? I think its impossible for the current AutoIt Version to read the htmlcode from an iFrame or do some other actions with the iFrame.thank you allbye Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2009 Share Posted March 24, 2009 Thanks, but the htmlcode is now without www.w3.org.i runned the script again, but the only thing i get is this empty source-code-msgbox:Whats faster & better? Open 100 IE's or run 100 iFrames? I think its impossible for the current AutoIt Version to read the htmlcode from an iFrame or do some other actions with the iFrame.thank you allbyeDid you ever try adding the error handler and running it in SciTE to see what errors might be there? The www.w3.org part was stupidity on my part. That's just part of the header, not the parent site.You could still have cross-site issues if the parent (whatever it is) is other than www.amazon.com. If you are creating a local html file for the parent document, then I believe www.amazon.com in a frame would be considered cross-site. Post the errors you get in the SciTE console - they will tell the tale. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iloveautoitv3 Posted March 25, 2009 Author Share Posted March 25, 2009 (edited) Did you ever try adding the error handler and running it in SciTE to see what errors might be there?I think this is what you mean, but i can't find out whats wrong.>"C:\Programme\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Dokumente und Einstellungen\co1\Desktop\www.autoitscript.com\get-iframe-source-code.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>09:53:14 Starting AutoIt3Wrapper v.1.9.2>Running AU3Check (1.54.13.0) from:C:\Program Files\AutoIt3+>09:53:15 AU3Check ended.rc:0>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Dokumente und Einstellungen\co1\Desktop\www.autoitscript.com\get-iframe-source-code.au3" --> COM Error Encountered in get-iframe-source-code.au3----> $IEComErrorScriptline = 2210----> $IEComErrorNumberHex = 80020009----> $IEComErrorNumber = -2147352567----> $IEComErrorWinDescription = Zugriff verweigert (access denied)----> $IEComErrorDescription = Zugriff verweigert (access denied)----> $IEComErrorSource = ----> $IEComErrorHelpFile = C:\WINDOWS\system32\mshtml.hlp----> $IEComErrorHelpContext = 0----> $IEComErrorLastDllError = 0+>09:53:32 AutoIT3.exe ended.rc:0+>09:53:33 AutoIt3Wrapper Finished>Exit code: 0 Time: 18.827 Edited March 25, 2009 by iloveautoitv3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 25, 2009 Share Posted March 25, 2009 I think this is what you mean, but i can't find out whats wrong.How about with some nice highlighting?! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iloveautoitv3 Posted March 25, 2009 Author Share Posted March 25, 2009 How about with some nice highlighting?!----> $IEComErrorWinDescription = Zugriff verweigert (access denied)----> $IEComErrorDescription = Zugriff verweigert (access denied)hmm, i dont know how to fix this problem...changed the <title>what the fuck</title>added <meta name="description" content="what the fuck"/>added to the iframe tags ... title="0001" ... longdesc="0001" i think i give up with this html-iframe-getting-the-source-thing. Now i gaved the embedded-thing a try and it woooooooooooorks !! #include <GUIConstants.au3>#include <IE.au3>_IEErrorHandlerRegister ()$iframe0001 = _IECreateEmbedded ()GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)$guiiframe0001 = GUICtrlCreateObj($iframe0001, 10, 40, 100, 100)GUISetState()_IENavigate ($iframe0001, "http://www.google.com")_IELoadWait ($guiiframe0001)$heyy0001 = _IEBodyReadHTML ($iframe0001)msgbox(1,"source1",$heyy0001)thank u allbye 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