_StringBetween help

04/11/2018 20:17 lenclstr746#1
Hi guys
I want to get "45.000"
HTML Code:
    <div id="header_credits" class="header_money">
        45.000
    </div>
from here :/ but stringbetween doesnt work on it
04/13/2018 14:17 lenclstr746#2
anyone help ???
04/13/2018 19:41 elmarcia#3
You have two ways of doing it, with dom elements using IE or with regexp, depends on what u want to do:
Code:
Func example1()
$html = '<div id="header_credits" class="header_money">45.000</div>'

$pattern = "(?m)(?s)<div.*>(.*?)</div>"

Local $reg = StringRegExp($html,$pattern,1)

;remove white space and CR from string
$result = StringStripWS($reg[0],8)
$result = StringReplace($result,@CRLF,"")
MsgBox(0,"",$result)
EndFunc

example1()

#include <IE.au3>
#include <Array.au3>

example2()


Func example2()
$oIE = _IECreate("https://www.cnbc.com/dow-components/")
_IELoadWait($oIE)


$table = $oIE.document.getElementsByTagName("tbody").item(0)

$rows = $table.getElementsByTagName("tr")
;name | price
Local $arr[$rows.length][2]

for $i =0 to $rows.length-1
$col = $rows.item($i).getElementsByTagName("td")
   for $c = 0 to $col.length -1
	  $att = $col.item($c).getAttribute("data-field")
	  if $att == "name" Then
		 $arr[$i][0] = $col.item($c).innerText
	  EndIf
	  if $att == "last" Then
		 $arr[$i][1] = $col.item($c).innerText
	  EndIf
   Next
Next

_ArrayDisplay($arr,"example","",0,Default,"NAME | PRICE")
EndFunc
04/13/2018 22:01 Moneypulation#4
You can get the number from that html code using stringbetween without a problem. Show us your code and we can try to figure out the problem