Am sorry if it may be very simple, I am a newbie, but I have researched a lot without finding how to click this option (XBT/USD) inside the dropdown list: https://ibb.co/jqf7zk
很抱歉,如果它可能很简单,我是一个新手,但我已经研究了很多,但没有找到如何在下拉列表中单击此选项(XBT / USD):https://ibb.co/jqf7zk
I only have managed to display the list with the code below, but I don't know how to select XBT/USD because this doesn't have an ID on html source.
我只是设法使用下面的代码显示列表,但我不知道如何选择XBT / USD,因为它在html源上没有ID。
Option Explicit
Sub BrowseToSite()
Dim IE As New SHDocVw.InternetExplorer
Dim oSelect As HTMLInputButtonElement
IE.Visible = True
IE.Navigate "https://www.kraken.com/charts"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
IE.Document.getElementById("pairselect-button").Click
End Sub
HTML code according to inspect element:
根据inspect元素的HTML代码:
< a tabindex="-1" class="currpairs" data-pair-text="XBT/USD" data-pair="XBTUSD">XBT/USD</a >
Thanks in advance for your valuable response.
提前感谢您的宝贵回复。
1 个解决方案
#1
1
You are almost there. You have found the dropdown menu. All you need to do is clicking XBT/USD
. The easiest method that comes to my mind is using getElementsByClassName
but you dont have to necessarily use it. You can find them by using xpath or tagname as well.
你快到了。你找到了下拉菜单。您只需点击XBT / USD即可。我想到的最简单的方法是使用getElementsByClassName,但你不必使用它。您也可以使用xpath或tagname找到它们。
Well, if you inspect the source you will see there are lots of class="currpairs"
. If you hover on them, you will see that they belong to each item in dropdown list. XBT/USD
is the second item in the list. So the missing part in your code is:
好吧,如果您检查源,您会看到有很多class =“currpairs”。如果将鼠标悬停在它们上,您将看到它们属于下拉列表中的每个项目。 XBT / USD是列表中的第二项。所以代码中缺少的部分是:
IE.Document.getElementsByClassName("currpairs")(1).Click
IE.Document.getElementsByClassName( “currpairs”)(1)。点击
Notice we used (1) after getting the class currpairs
. This is because counting starts from 0 in list. So (0) represents the first item XBT/EUR
, and (1) represents the second item XBT/USD
in the list.
注意我们在获得课程currpairs后使用(1)。这是因为计数从列表中的0开始。因此(0)表示第一项XBT / EUR,(1)表示列表中的第二项XBT / USD。
Hope this helps.
希望这可以帮助。
#1
1
You are almost there. You have found the dropdown menu. All you need to do is clicking XBT/USD
. The easiest method that comes to my mind is using getElementsByClassName
but you dont have to necessarily use it. You can find them by using xpath or tagname as well.
你快到了。你找到了下拉菜单。您只需点击XBT / USD即可。我想到的最简单的方法是使用getElementsByClassName,但你不必使用它。您也可以使用xpath或tagname找到它们。
Well, if you inspect the source you will see there are lots of class="currpairs"
. If you hover on them, you will see that they belong to each item in dropdown list. XBT/USD
is the second item in the list. So the missing part in your code is:
好吧,如果您检查源,您会看到有很多class =“currpairs”。如果将鼠标悬停在它们上,您将看到它们属于下拉列表中的每个项目。 XBT / USD是列表中的第二项。所以代码中缺少的部分是:
IE.Document.getElementsByClassName("currpairs")(1).Click
IE.Document.getElementsByClassName( “currpairs”)(1)。点击
Notice we used (1) after getting the class currpairs
. This is because counting starts from 0 in list. So (0) represents the first item XBT/EUR
, and (1) represents the second item XBT/USD
in the list.
注意我们在获得课程currpairs后使用(1)。这是因为计数从列表中的0开始。因此(0)表示第一项XBT / EUR,(1)表示列表中的第二项XBT / USD。
Hope this helps.
希望这可以帮助。