所以,我收到了很多次的短信。这一次,它根本不起作用。尝试过很多其他的方法。
首先,我在VBA上使用Selenium来使用chromedriver。来源网站是"area=1536]“,这个网站运行在一个Iframe上。经过半个小时的尝试从里面获取文本,我认为它的代码中的链接工作得同样好:"[http://publica.agnet.fazenda.df.gov.br/FichaImovel/#/FichaCadastral]“。最后一种似乎是在某种叫做“角”的情况下运作的。
我所需要的带有内部文本的菜单是下拉菜单。作为一个虚拟值,您可以使用50868748。它生成的下拉文本由15行和一个表组成。我需要的信息是在第15行,"Nome do Responsável",或者在表上的第2列第2行。
我设法放置代码并生成下拉列表,但无法获得内部文本。
这是我的代码:
Dim iptu As StringDim driver As New ChromeDriver
With driver
.Start
iptu = 50868748 'dummy
.Get "http://publica.agnet.fazenda.df.gov.br/FichaImovel/#/FichaCadastral"
.FindElementById("inscricaoImovel").Clear
.FindElementById("inscricaoImovel").SendKeys iptu
.FindElementsById("btnCadastro")(2).Click
.Wait (300)“在这里之前,一切都很好
Dim label As Object
Dim name As String
Set label = .FindElementsByClass("ng-binding")(91)
'as you can see, i end up using this class(91) to get the value on the table, but i can get from the 15th line too
name = label.getAttribute("innerText") 'Error is here我尝试过.innerText、.innerHTML和其他。错误总是"object不接受属性或方法“错误438。
end with镀铬驱动器是最新的。此外,网页来源不提供我需要的信息。
有人能帮我吗?
发布于 2018-11-13 19:00:10
要获得元素的InnerText,需要调用Text方法
Set label = .FindElementsByClass("ng-binding")(91)
name = label.Text要获得内部Html,
name = label.Attribute("innerHTML")发布于 2018-11-13 19:08:00
有时,我发现我必须执行javascript才能得到我想要的东西。你可以试试
name=driver.ExecuteScript("document.getElementsByClassName('ng-binding')[91].innerText;")https://stackoverflow.com/questions/53287630
复制相似问题