Jump to content

Copy text from HTML, StringBetween EOL


 Share

Recommended Posts

Hello everyone!

 

What I have (HTML CODE):

p1.PNG

 

My autoit code:

Quote

$sPhoneNumber = _StringBetween(_IEDocReadHTML($oIE) , '<SPAN style="FONT-WEIGHT: bold">Mensagem:</SPAN></TD></TR>', 'Linha')


MsgBox(0,0, $sPhoneNumber[0])


FileWrite($hFilehandle, $sPhoneNumber[0])

 

What I get (message and file):

p2.PNGp3.PNG

 

What I want:

p4.PNG

 

The main question here is how do I put End Of Line in _StringBetween?

 

Thanks in advance!

 

Link to comment
Share on other sites

Have you taken into account @CR and @LF of the form?  You may need to do a StringReplace or StringRegExReplace of the InnerHTML first before using _StringBetween alternatively you could also use something like:

#include <IE.au3>

$oiE = _IECreate("http://somesite.com", 1)
$oTRS = _IETagNameGetCollection($oiE, "tr")
For $oTR in $oTRS
    If $oTR.InnerText = "Mensagem: " Then
        MsgBox(0,'', "InnerHTML = " & $oTR.nextElementSibling.innerHTML)
        MsgBox(0,'', "InnerText = " & $oTR.nextElementSibling.innerText)
    EndIf
Next

 

Link to comment
Share on other sites

10 hours ago, Subz said:

Have you taken into account @CR and @LF of the form?  You may need to do a StringReplace or StringRegExReplace of the InnerHTML first before using _StringBetween alternatively you could also use something like:

#include <IE.au3>

$oiE = _IECreate("http://somesite.com", 1)
$oTRS = _IETagNameGetCollection($oiE, "tr")
For $oTR in $oTRS
    If $oTR.InnerText = "Mensagem: " Then
        MsgBox(0,'', "InnerHTML = " & $oTR.nextElementSibling.innerHTML)
        MsgBox(0,'', "InnerText = " & $oTR.nextElementSibling.innerText)
    EndIf
Next

 

Thanks!!! The @CRLF worked great. It was a very newbie question!

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