[AutoIT] get information by ie.au3

05/19/2017 13:56 Melli-#1
I have this line

<div class="onlysample">lol</div>

How I can read out this "lol" and do it in a listbox from the ie.au3.

Notice: Next time the "lol" is different, it's for example "lol2" or "lol59095"
05/19/2017 21:41 Moneypulation#2
You can use _StringBetween to find the value inside the div container, but what do you mean with "do it in a listbox from the ie.au3"? is there a listbox on the webpage and you want to add this as an item or do you want to do that in your AutoIt Form?
05/20/2017 11:06 Melli-#3
Quote:
Originally Posted by Moneypulation View Post
You can use _StringBetween to find the value inside the div container, but what do you mean with "do it in a listbox from the ie.au3"? is there a listbox on the webpage and you want to add this as an item or do you want to do that in your AutoIt Form?
There are div's and I want to add for one div string a new list item.
05/20/2017 22:52 xShizoidx#4
Habe hierfür mal kurz eine Funktion erstellt :

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

$IE = _IECreate("http://getbootstrap.com/components/#alerts")

$htmlTags = _IETagNameAllGetCollection($IE):

$result = getTextContentByClassName("alert alert-success")
_ArrayDisplay($result)

Func getTextContentByClassName($className)
   Local $textContents = []
   For $tag in $htmlTags
	   $classValue = $tag.GetAttribute("class")
		 If StringInStr($classValue,$className) > 0 Then
			_ArrayAdd($textContents,$tag.innerText)
		 EndIf
	  Next
   $textContents[0] = UBound($textContents)-1
   return $textContents
EndFunc
05/24/2017 03:51 symphonick#5
Code:
Local $sSourceHTML ; your source by InetGet or other
Local $aArray = StringRegExp($sSourceHTML, '<div class="onlysample">(lol\d*)</div>', 1) ; simples quotes because they are doubles quotes in pattern
Local $sLolOut = $aArray[0] ; done