Sedoc94 Posted July 9, 2012 Share Posted July 9, 2012 (edited) <abbr class="timestamp">inner text example</abbr>I would like to make AutoIt search in the website's source for the abbr tag with classname timestamp and return me the innertext of it.How would I go about doing that, though? :/Your help is very much appreciated! Thanks a lot! Edited July 9, 2012 by Sedoc94 Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 9, 2012 Share Posted July 9, 2012 (edited) #include<array.au3> $sSource='inner text example' $aResult=StringRegExp($sSource,'(.*)',3) _arraydisplay($aResult) Edited July 9, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Sedoc94 Posted July 9, 2012 Author Share Posted July 9, 2012 (edited) Hmm, well that won't work because the <abbr> has got some other attributes that are dynamic (changes everytime), so I basically really need to check for the tag with the classname and then return the inner text of it. Better example below <abbr class="timestamp" data-utime="1341863797" title="Monday, July 9, 2012 at 9:56pm">inner text example</abbr> Edited July 9, 2012 by Sedoc94 Link to comment Share on other sites More sharing options...
jdelaney Posted July 9, 2012 Share Posted July 9, 2012 If you have the xml saved as a file, use load...if you have the xml as a string, use loadxml $oXML=ObjCreate("Microsoft.XMLDOM") $stest = @DesktopDir & "xml.xml" $oXML.Load($stest) ConsoleWrite ( $oXML.xml & @CRLF) $result = $oXML.selectSingleNode('//abbr') msgbox ( 4096, "test", $result.text ) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Sedoc94 Posted July 9, 2012 Author Share Posted July 9, 2012 No, this is not about a XML file, but about a website source code. HTML5 which contains the abbr tags. Link to comment Share on other sites More sharing options...
jdelaney Posted July 9, 2012 Share Posted July 9, 2012 html, xml, what's the diff. read in the document body, and it will work...or you can use the _IE* functions IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Sedoc94 Posted July 9, 2012 Author Share Posted July 9, 2012 As I'm not good as this, this now confuses me a lot. So it's not that easy for me to transform your example script to make it work. Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 9, 2012 Share Posted July 9, 2012 (edited) Oops, sry, the following should work for you. #include<array.au3> $sSource='<abbr class="timestamp" data-utime="1341863797" title="Monday, July 9, 2012 at 9:56pm">inner text example</abbr>' $aResult=StringRegExp($sSource,'<abbr (?:.*?)>(.*)</abbr>',3) _arraydisplay($aResult) Edited July 9, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Sedoc94 Posted July 9, 2012 Author Share Posted July 9, 2012 Alright, I managed to transform your code into: #include <Inet.au3> $URL = 'http://www.example.com' $urlSource = _INetGetSource($URL) $Match = StringRegExp($urlSource,'<abbr (?:.*?)>(.*)</abbr>',3) MsgBox(0, "", $Match[0]) But the thing is now that _INetGetSource takes very long to get the source, about 6 seconds long. Isn't there a way to speed up the process of getting the source? Thanks Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 9, 2012 Share Posted July 9, 2012 Isn't there a way to speed up the process of getting the source?Get, "fiber to the home"? Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Sedoc94 Posted July 9, 2012 Author Share Posted July 9, 2012 Well, it's not my internet. It's just the source code is like thousands of lines long, I guess that's the reason why it take so long. But it would be nice if the function would stop getting more of the source when it has reached the tag. 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