Sign in to follow this  
Followers 0
Sedoc94

How to get the inside text from <abbr> tag?

11 posts in this topic

#1 ·  Posted (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 by Sedoc94

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 by Sedoc94

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

No, this is not about a XML file, but about a website source code. HTML5 which contains the abbr tags.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. :(

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by DicatoroftheUSA

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0