EmptySpace Posted June 5, 2012 Share Posted June 5, 2012 (edited) Just cant find out how to: Click changing link. For example link is www.google.com/wmd after its clicked that wmd changes like www.google.com/lmk . So how I should click it ignoring these letters?Continen of that link is same. Btw link is on/in javascript or something. But no matter i think. I found this in russian forum (firstly translated in english ofcorse) $OLinks = _IELinjGetCollection($oIE) ; $oIE before created ie window For $OLinks in $OLink ; cant understand why needs this line If (StringInStr($OLink.Innertext, "some text?")) Then ; not sure about these ones Do something EndIf Next Second, reading text from web page like "points left : 1000" That 1000 number always changes and I need to show it In my created GUI corner (I know how to do) but i dont know how to read whole line and that changing number. This is to show me how many point i have from forum. Its kinda forum when u do some activity and collect points so I just want to know fastly how much I have. Thanks Edited June 5, 2012 by Edgaras Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 5, 2012 Share Posted June 5, 2012 Try this; changeIf (StringInStr($OLink.Innertext, "some text?")) Then toIf StringInStr($OLink.Innertext, "some text?") Or StringInStr($OLink.Innertext, "some other text?") ThenI removed the extra set of parentheses, I don't think they're needed. But I'm usually wrong more than I'm right.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 6, 2012 Author Share Posted June 6, 2012 Whatever, Idk if that works. Now I have to solve how to click javascript link. Getting text or something not works. Maybe need something like java udf or what?... Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 6, 2012 Share Posted June 6, 2012 The question how to click j/s links has been asked here many times (well, more than once..). I don't know if the question was resolved, but search thru here and see. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 6, 2012 Author Share Posted June 6, 2012 Yeah I spent some time on searching for it but didnt found any solution. What I need to do now is to move on onther things. Like how to read text section but cant find out how to do that. Its possible to read all text in browser window but i need just one sentence... Cant find info about it too.. thats why i started learning c# Link to comment Share on other sites More sharing options...
lark Posted June 7, 2012 Share Posted June 7, 2012 Can't you just get the object of where the text is and then use $oText.Innertext? So the code you posted above was for the link, but isn't that what you need for just a sentence? Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 Its not button or something, just text like " <u>Some text<u> " Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 Hmm... ok... so how I should get text from button in web? Do _IEGetObjByName/id And how to return text which is in it? Cant solve it.. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 7, 2012 Share Posted June 7, 2012 Can you post the URL to the webpage? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 for example this http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro edit and click me button. I need to read his value Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 7, 2012 Share Posted June 7, 2012 I used two functions _StringBetween and _INetGetSource here, but this can probably be done some other way.#include <String.au3> #include <INet.au3> Local $Array = _StringBetween(_INetGetSource('http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro'), 'type="submit" value="', '»" onclick=') ConsoleWrite(@LF & $Array[0] & @LF & @LF) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 Thanks but I cant understand this line 'type="submit" value="', '»" onclick=') maybe this would work with not only buttons? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 7, 2012 Share Posted June 7, 2012 _StringBetween - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 Oh didnt saw ) So with this func I can read correct strings from whole source which I want for example sentence in <u>text<u> ? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 7, 2012 Share Posted June 7, 2012 Yes. You might have to experiment to find the working start and end values. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 Its difficult/impossible to find right string in whole window. Link to comment Share on other sites More sharing options...
lark Posted June 7, 2012 Share Posted June 7, 2012 (edited) I find that taking the body text and using lots of string manipulation is over complicated. Another thing you could do would be to get the tag name of the button, which would be "input". well here is how you could retrieve the text in the button: #include <IE.au3> Global $oBrowser = _IECreate("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro"); open IE Global $oButton = _IETagNameGetCollection($oBrowser, "input", 0); get the object of the button MsgBox(0,'', $oButton.value); display the data in the value tag of our object, which is the text we wanted to see In your case, you can find what instance your text would be under the tag name 'u', and access its "innertext" tag or whatever. Its difficult/impossible to find right string in whole window. Eh? Can't you just inspect the element? If you are using google chrome, right-click the element and select "Inspect Element". Otherwise, find an add-on (such as firebug) and install that. I think IE has a built in DOM inspector thing as well. Edit: but then i would recommend just getting its tag name and stuff, not finding strings around it to use with _StringBetween or something. Edited June 7, 2012 by lark Link to comment Share on other sites More sharing options...
EmptySpace Posted June 7, 2012 Author Share Posted June 7, 2012 No no no I have firebug and always using it and bunch of firefox addons to inspect elements. I want to get text and place it to gui or somewhere else. _IETagNameGetCollection($oBrowser, "input" it will take all inputs, right? So it works only where is one button... Link to comment Share on other sites More sharing options...
lark Posted June 7, 2012 Share Posted June 7, 2012 No no no I have firebug and always using it and bunch of firefox addons to inspect elementsI must have misinterpreted you, I apologize. No no no I have firebug and always using it and bunch of firefox addons to inspect elementsYes, it takes all inputs. But if you look at the third parameter of _IETagNameGetCollection, you specify the index of the element. So if it were the third input on the webpage, then you could specify the index to be 2. Also, suppose there were like 38 or so inputs before it. But then, maybe there is a form (or some other less common tag) right before your element. Instead of counting how many elements there are before the one you want, you could make use of the anarchy structure of the DOM by taking that form. Then your element might be only the 5th or so input after that form. Here is an example that retrieves the latest post of the AutoIt General Help and Support forum. #include <IE.au3> Global $oBrowser = _IECreate("http://www.autoitscript.com/forum/") Global $oHighTable = _IETagNameGetCollection($oBrowser, "table", 1) Global $oMidTR = _IETagNameGetCollection($oHighTable, "tr", 1) Global $oLowTD = _IETagNameGetCollection($oMidTR, "td", 3) Global $oA = _IETagNameGetCollection($oLowTD, "a", 1) ConsoleWrite("Latest Post in General Help and Support: " & $oA.title & @CRLF) So instead of counting how many elements there are with a tag name 'a', I took other elements lower in the DOM and built my way up to the element I wanted to work with. 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