getElementsByClassName() <> innerText <> innerHTML

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

effel
Posts: 549
Joined: 16 Jan 2018, 13:34

getElementsByClassName() <> innerText <> innerHTML

31 Jul 2023, 13:31

Guten Abend,

ich versuche mit meinem Code einen Link zu erreichen, bekomme jedoch nur alle angezeigt.

Wie ich mit anderen Bordmitteln wie [loop, parse] daran komme weiss ich, mir stellt sich nur die Frage ob es auch durch abändern von res#Test[a_index-1].innerHTML möglich ist einzelne Links aus dem HTML Code zu saugen.



Code: Select all

; #STARTinnerTextTHREAD_14
Automatically changes "am" to "AM" (w/ font size) 

Last post by BannerStore « Yesterday, 16:50 

by BannerStore » Yesterday, 16:50 
; #ENDinnerTextTHREAD_14

; #STARTinnerHTMLTHREAD_14


						
						<a class="topictitle" href="./viewtopic.php?f=6&amp;t=119924">Automatically changes "am" to "AM" (w/ font size)</a>

						
						
						<br>



						


						
						<div class="responsive-show" style="display: none;">

							Last post by <a class="username" href="./memberlist.php?mode=viewprofile&amp;u=81634">BannerStore</a> « <a title="Go to last post" href="./viewtopic.php?f=6&amp;t=119924&amp;p=532104#p532104">Yesterday, 16:50</a>

							
						</div>

						
						


						


						<div class="responsive-hide">

							
							
							by <a class="username" href="./memberlist.php?mode=viewprofile&amp;u=81634">BannerStore</a> » Yesterday, 16:50

							
						</div>



						
					
; #ENDinnerHTMLTHREAD_14

Code: Select all


url := "https://www.autohotkey.com/boards/viewforum.php?f=6"

#Warn ,,Off
#NoEnv
urlDownLoadToFile,% url,% a_scriptDir "\" anow " tmp.txt.html" 
fileRead, thisHTML,% a_scriptDir "\" anow " tmp.txt.html"
fileDelete,% a_scriptDir "\" anow " tmp.txt.html"

Doc := DocumentFromHTML(thisHTML)

testSuche = topiclist topics
testSuche = pagination
;testsuche = next
testSuche = list-inner
;testsuche = topictitle

 res#test 	:= doc.getElementsByClassName(testSuche)
res#TestLength := res#Test.length

loop, % (res#TestLength ? res#TestLength : 100)
{
try #Test 	.= 	(res#Test[a_index-1].innerText) 
		? ("`; #STARTinnerTextTHREAD_" a_index "`n" res#Test[a_index-1].innerText  "`n`; #ENDinnerTextTHREAD_" a_index "`n")  
		: "`; #STARTinnerTextTHREAD_" a_index "`n`; #emptyinnerText`n`;#ENDinnerTextTHREAD_" a_index "`n"
}


loop, % (res#TestLength ? res#TestLength : 100) 
{
try #Test 	.= 	(res#Test[a_index-1].innerHTML) 
		? ("`; #STARTinnerHTMLTHREAD_" a_index "`n" res#Test[a_index-1].innerHTML "`n`; #ENDinnerHTMLTHREAD_" a_index "`n")  
		: "`; #STARTinnerHTMLTHREAD_" a_index "`n`; #emptyINNERHTML`n`;#ENDinnerHTMLTHREAD_" a_index "`n"
}

msgBox % #Test
effel
Posts: 549
Joined: 16 Jan 2018, 13:34

Re: getElementsByClassName() <> innerText <> innerHTML

01 Aug 2023, 09:09

ich habe die Lösung, danke fürs lesen
boiler wrote:
12 Nov 2019, 08:08
3ggg wrote: 2nd question, if I want the link i just replace .innerText with .href right?
Yes, generally that will give you the link URL if there is one associated with it.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: just me and 39 guests