gspot Posted September 5, 2014 Posted September 5, 2014 Hi! Im trying to get an element from a page using javascript in autoit, searching the forum i didnt find much about the subject. I tryed this simple example #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE, $oElem $oIE = _IECreate("https://www.autoitscript.com/site/", 0, 0) $oElem = $oIE.document.getElementsByTagName('p')[1].innerText msgbox(0, "", $oElem) In a javascript console document.getElementsByTagName('p')[1].innerText gives "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting..." But when i try in autoit it gives the error (6) : ==> Subscript used on non-accessible variable.: $oElem = $oIE.document.getElementsByTagName('p')[1].innerText $oElem = $oIE.document.getElementsByTagName('p')^ ERROR Can someone help?
JohnOne Posted September 5, 2014 Posted September 5, 2014 Try $oElem = $oIE.document.getElementsByTagName('p').innerText AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
gspot Posted September 5, 2014 Author Posted September 5, 2014 Try $oElem = $oIE.document.getElementsByTagName('p').innerText Didnt work for me, no error, but doesnt return the text...
bogQ Posted September 5, 2014 Posted September 5, 2014 you need to check do $oIE.document.getElementsByTagName('p') return array? TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
gspot Posted September 5, 2014 Author Posted September 5, 2014 you need to check do $oIE.document.getElementsByTagName('p') return array? No.
Solution bogQ Posted September 5, 2014 Solution Posted September 5, 2014 $oElem = $oIE.document.GetElementsByTagName("p").item(1).innerText() TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
MikahS Posted September 5, 2014 Posted September 5, 2014 (edited) #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE, $oElem $oIE = _IECreate("https://www.autoitscript.com/site/", 0, 1, 1) $oElem = $oIE.document.GetElementsByTagName("p").item(1).innerText() MsgBox(0, "", $oElem) EDIT: bogQ beat me to it Edited September 5, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
trancexx Posted September 5, 2014 Posted September 5, 2014 .innerText is property, not method. That means the last set of parentheses shouldn't be there. Also, .item is default property, meaning it can be omitted: $oIE.document.GetElementsByTagName("p")(1).innerText ...Disable buggy AU3Check before running that. ♡♡♡ . eMyvnE
bogQ Posted September 5, 2014 Posted September 5, 2014 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
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