Jump to content

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


Recommended Posts

<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
Link to comment
Share on other sites

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
Link to comment
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.
Link to comment
Share on other sites

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
Link to comment
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 :)

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...