11 posts in this topic
I'm using an online translator for Spanish in which you give the verb and website gives the conjugations. The website I'm using is: http://www.spanishdict.com/conjugate/tener where "tener" means "to have" in English.
In the screenshot, you can see the present tense (5 yellow highlighted items) and the imperfects (5 blue boxes). I don't need to get the translation for "vosotros", so I didn't make any color on that row. I'm trying to get these 10 translations to be written on the output for my code. But my code is so simple (because I couldn't go into the div / tr / td):
#include <IE.au3> #include <Array.au3> Local $sSpanishWord = "tener" ;to have ;Local $sSpanishWord = "abrir" ;to open Local $oIE = _IECreate ("http://www.spanishdict.com/conjugate/" & $sSpanishWord) ;http://www.spanishdict.com/conjugate/tener ;http://www.spanishdict.com/conjugate/abrir ;== Try using _IETagNameAllGetCollection Local $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.id Then ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText & @CRLF & @CRLF) EndIf Next ;== Try using _IETagNameGetCollection Local $sTable Local $oTableCells Local $oTableRows = _IETagNameGetCollection($oIE, "tr") For $oTableRow In $oTableRows $sTable = "" $oTableCells = _IETagNameGetCollection($oTableRow, "td") ;I don't know how to continue from here on Next I used the IE to find out the tr / td stuff, but I think I'm lost.
P.S: The verb "tener" can be difficult, because it has red letters because of irregular. The verb "abrir" can be much easier, because it's a regular verb.
I am very new to AutoIt and scripting in general and have a question about IEFormGetObjByName. The help function says:
_IEFormGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )
But how do I find what to enter for $sName? In the example below, it says that it can be found by viewing the HTML source. So I went to the google home page, clicked Ctrl U to view the source, and cant figure out how they determined that the $sName is 'gbqf'. Can someone explain this process to me? Thanks in advance!
; Get a reference to a specific form by name. In this case, submit a query
; to the Google search engine. Note that the names of the form and form
; elements can be found by viewing the page HTML source
Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
Hello I'm trying to translate few text using below code, I found it working previously couple of months ago but Now these days it's not working at all and I'm getting below errors when I run the script and Array display at the end of text also not able to show any translated text instead of value 0 & 1;
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (gt-res-data)
--> IE.au3 T3.0-2 Error from function _IEPropertyGet, $_IESTATUS_InvalidDataType
Here is code,
#include <IE.au3> #include <Array.au3> Local $tag="* # * # *" Local $oIE=_IECreate("https://translate.google.com/#auto/es") Local $oForm=_IEFormGetCollection($oIE,0) Local $oQuery=_IEGetObjByName($oForm,"text") _IEFormElementSetValue($oQuery, $tag & @CR & "Hello World" & @CR & "This is a test" & @CR & $tag) _IEFormSubmit($oForm) _IELoadWait($oIE) Local $oText=_IEGetObjById($oIE,"gt-res-data") $lines=StringSplit(_IEPropertyGet($oText,"innerText"),@CRLF,1) _IEQuit($oIE) _ArrayDelete($lines,_ArraySearch($lines,$tag,1,0,0,1,0) & "-" & $lines) _ArrayDelete($lines,"1-" & _ArraySearch($lines,$tag,1,0,0,1,1)) $lines=UBound($lines)-1 _ArrayDisplay($lines)
Hey, i hope someone can point me in the right direction, i have a page with tables, inside i have TD,TR,INPUT tags, the input tags is buttons and i need to click on one of theese buttons but they have the same value and type so the only way that i am going to know that it's the correct button is to find out the name of the innerhtml of the TD before (the parent node) because the input comes after, like this
<TABLE> <TR> <TD> Name of the td </TD> <TR> <TD colSpan=3<INPUT> value=my button type=button</INPUT></TD> <TR> <TD> Other name of a td </TD> <TR> <TD colSpan=3<INPUT> value=my button type=button</INPUT></TD> <TR> I know how to find all td's and inputs but not (in a loop) look for the td's and once it has found it click on the corresponding or "closest" input, maybe a nested loop?
I made a for loop using _IETagnameGetCollection($ie,"TD") and after it found the TD i tried looking for nextSibling but that might be impossible with INPUT perhaps?
Let's take a simple example to illustrate my case.
I open a webpage with the command _IECreate and I parse all its elements :
#include <IE.au3> $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & "Id: " & $oElement.id & @CRLF & "InnerText: " & $oElement.innerText & @CRLF & "--------------------------------" & @CRLF) Next Now let's imagine I simulate a click with MouseClick to the link "lesson two" at the bottom of this webpage. A new webpage will open :
I'd like to get the elements (tagname, id, innertext) of this new webpage, just like I got them for the first webpage. But for this, I presume I would have to get a new $oIE2 Object variable of an InternetExplorer.Application, in order to be able to use the _IETagNameAllGetCollection once again.
How am I supposed to do this ?
Thank you !