What's the name for this element area in this pages “inspect element”?

Get help with using AutoHotkey and its commands and hotkeys
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

What's the name for this element area in this pages “inspect element”?

21 Dec 2020, 18:12

I'm trying to use this script to list the pace figures displayed in a specific section of the element - but "ele.innerText" isn't working to display the pace figures

So I'm wondering what I should replace "ele.innerText" with so that the pace figures will be displayed

Heres a gif of the element area im trying to download (for each horse, theres 11 horses in this race) , the pace figures are all listed in the "card-entry" classnames https://gfycat.com/SameLastingHadrosaurus
and heres a link to the page itself https://www.attheraces.com/racecard/Huntingdon/22-December-2020/1535/pacechart

Code: Select all

    URL := "https://attheraces.com/racecard/Huntingdon/22-December-2020/1535/pacechart" 
        tooltip Downloading page
        page:=download(URL) ; Download page to memory
        tooltip
    
        document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
        document.write(page)
    
        elements:=document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
        loop {
            try ele:=elements[A_Index-1] ; loop through each element
            catch ; Above line gives error when we run out of elements
                break ; Then we break out of loop
            msgbox % ele.innerText ; Display its innerText for example
        }
    
        return
    
    
        ;Ref: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#WHR
        Download(url){
            whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
            whr.Open("GET", url, true)
            whr.Send()
            whr.WaitForResponse()
            return whr.ResponseText
        }
User avatar
Xtra
Posts: 2048
Joined: 02 Oct 2015, 12:15

Re: What's the name for this element area in this pages “inspect element”?

21 Dec 2020, 18:41

On that page open chrome dev tools (press F12 or Ctrl+Shift+J) and enter this document.getElementsByClassName("card-entry")[0].innerTexton the Console tab.
AHKStudent
Posts: 1052
Joined: 05 May 2018, 12:23

Re: What's the name for this element area in this pages “inspect element”?

21 Dec 2020, 23:56

based on what xtra said try this

Code: Select all

    URL := "https://attheraces.com/racecard/Huntingdon/22-December-2020/1535/pacechart" 
        tooltip Downloading page
        page:=download(URL) ; Download page to memory
        tooltip
    
        document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
        document.write(page)
    
        elements:=document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
        loop {
            try ele:=elements[A_Index-1].innerText ; loop through each element
            catch ; Above line gives error when we run out of elements
                break ; Then we break out of loop
            msgbox % ele ; Display its innerText for example
        }
    
        return
User avatar
Xeo786
Posts: 361
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: What's the name for this element area in this pages “inspect element”?

22 Dec 2020, 01:22

when you get all elements from html or IE it will make an object which has key called length and you can simply call it elements.length

Code: Select all

elements := document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
loop, % elements.length
	msgbox, elements[A_Index-1].innerText
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

22 Dec 2020, 08:36

I tried AHKStudent script but for some reason it gives error "call to nonexistant function" https://i.imgur.com/HnDJvY9.png

also tried using Xeo786's but it just said "elements[a_index-1].innertext https://i.imgur.com/PlijnTX.png

Code: Select all

URL := "https://attheraces.com/racecard/Huntingdon/22-December-2020/1535/pacechart" 
    tooltip Downloading page
    page:=download(URL) ; Download page to memory
    tooltip

    document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
    document.write(page)

elements := document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
loop, % elements.length
	msgbox, elements[A_Index-1].innerText


    return


    ;Ref: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#WHR
    Download(url){
        whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
        whr.Open("GET", url, true)
        whr.Send()
        whr.WaitForResponse()
        return whr.ResponseText
    }
gregster
Posts: 5784
Joined: 30 Sep 2013, 06:48

Re: What's the name for this element area in this pages “inspect element”?

22 Dec 2020, 08:41

autohotkeycool wrote:
22 Dec 2020, 08:36
I tried AHKStudent script but for some reason it gives error "call to nonexistant function" https://i.imgur.com/HnDJvY9.png

also tried using Xeo786's but it just said "elements[a_index-1].innertext https://i.imgur.com/PlijnTX.png
Didn't try either code, but you have the missing function named Download in your original code in the first post of this topic. So that shouldn't be an issue.

Also, there is probably only a % missing : msgbox, % elements[A_Index-1].innerText
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

22 Dec 2020, 08:58

ta, I added that % key in there and Xeo786's runs now

but it doesn't appear to show the Pace number for the page I download

E.g. As you can see here "barbarian" pace is 8 https://i.imgur.com/yf9Zmkp.png

but the downloaded page doesn't say 8 on it anywhere

I'm trying to download the section of the element that has the pace rating figure on it

Code: Select all

URL := "https://t.attheraces.com/racecard/Exeter/01-January-2021/1555/pacechart" 
    tooltip Downloading page
    page:=download(URL) ; Download page to memory
    tooltip

    document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
    document.write(page)

elements := document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
loop, % elements.length
	msgbox, % elements[A_Index-1].innerText


    return


    ;Ref: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#WHR
    Download(url){
        whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
        whr.Open("GET", url, true)
        whr.Send()
        whr.WaitForResponse()
        return whr.ResponseText
    }
Last edited by autohotkeycool on 30 Dec 2020, 11:37, edited 3 times in total.
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

25 Dec 2020, 16:17

Or is it not possible to download the section of the element that contains the pace figures?
User avatar
Xtra
Posts: 2048
Joined: 02 Oct 2015, 12:15

Re: What's the name for this element area in this pages “inspect element”?

25 Dec 2020, 17:38

autohotkeycool wrote:
25 Dec 2020, 16:17
Or is it not possible to download the section of the element that contains the pace figures?
document.getElementsByClassName("track__bar js-width js-width--is-initialised")[6].style.width = 90%
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

25 Dec 2020, 19:03

Thanks for the reply, one minor problem it sayts "this line paramater contains a variable name missing it's ending percent sign"

https://i.imgur.com/vx8Bt0l.png

Code: Select all

URL := "https://attheraces.com/racecard/Huntingdon/22-December-2020/1535/pacechart" 
    tooltip Downloading page
    page:=download(URL) ; Download page to memory
    tooltip

    document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
    document.write(page)

elements := document.getElementsByClassName("track__bar js-width js-width--is-initialised")[6].style.width=90%
loop, % elements.length
	msgbox, % elements[A_Index-1].innerText


    return


    ;Ref: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#WHR
    Download(url){
        whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
        whr.Open("GET", url, true)
        whr.Send()
        whr.WaitForResponse()
        return whr.ResponseText
    }
User avatar
Xtra
Posts: 2048
Joined: 02 Oct 2015, 12:15

Re: What's the name for this element area in this pages “inspect element”?

26 Dec 2020, 01:17

I was just showing the result which is 90%
try:
Msgbox % elements := document.getElementsByClassName("track__bar js-width js-width--is-initialised")[6].style.width

if you want to loop over all the elements of that type:

Code: Select all

elements := document.getElementsByClassName("track__bar js-width js-width--is-initialised")
loop, % elements.length
	msgbox, % elements[A_Index-1].style.width
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

26 Dec 2020, 04:29

Xtra wrote:
25 Dec 2020, 17:38
autohotkeycool wrote:
25 Dec 2020, 16:17
Or is it not possible to download the section of the element that contains the pace figures?
document.getElementsByClassName("track__bar js-width js-width--is-initialised")[6].style.width = 90%
ah I understand what you mean now, so it does give the pace figures, the 90% is pace of 9



but where did you get this result? When I run the script I mentioned in this post https://www.autohotkey.com/boards/viewtopic.php?f=76&t=84774#p371987

there's no

document.getElementsByClassName("track__bar js-width js-width--is-initialised")[6].style.width[/c] = 90%

to be found in the popup box

Image
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: What's the name for this element area in this pages “inspect element”?

30 Dec 2020, 11:38

autohotkeycool wrote:
22 Dec 2020, 08:58
ta, I added that % key in there and Xeo786's runs now

but it doesn't appear to show the Pace number for the page I download

E.g. As you can see here "barbarian" pace is 8 https://i.imgur.com/yf9Zmkp.png

but the downloaded page doesn't say 8 on it anywhere

I'm trying to download the section of the element that has the pace rating figure on it

Code: Select all

URL := "https://t.attheraces.com/racecard/Exeter/01-January-2021/1555/pacechart" 
    tooltip Downloading page
    page:=download(URL) ; Download page to memory
    tooltip

    document := ComObjCreate("HTMLFile") ; Create an HTML file in memory
    document.write(page)

elements := document.getElementsByClassName("card-entry") ; Get elements with class "card-entry"
loop, % elements.length
	msgbox, % elements[A_Index-1].innerText


    return


    ;Ref: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#WHR
    Download(url){
        whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
        whr.Open("GET", url, true)
        whr.Send()
        whr.WaitForResponse()
        return whr.ResponseText
    }
would anyone have any idea what changes I need so that the page that downloads will show the pace ratings?

Return to “Ask For Help”

Who is online

Users browsing this forum: Bar_Dres, Spawnova, XMCQCX and 46 guests