我正在尝试从以下站点中删除条形码所有者:http://gepir.gs1.org/index.php/search-by-gtin
由于最后一行,我收到“对象不支持此属性或方法”错误消息。我试图用类和标签提取它,但是失败了。
我正在尝试从动态表中提取公司名称。
Sub aa()
Dim ie As New SHDocVw.InternetExplorer
Dim doc As HTMLDocument
Dim aaa As Object
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
ie.Visible = True
ie.navigate "gepir.gs1.org/index.php/search-by-gtin"
Do While ie.readyState <> READYSTATE_COMPLETE
Loop
Debug.Print ie.LocationName, ie.LocationURL
Set doc = ie.document
ie.document.forms("searchbygtin").elements("keyValue").Value = "685387379712"
ie.document.forms("searchbygtin").elements("method").Click
Debug.Print ie.document.getElementsBytag("tr")(7).innerText
End Sub
任何帮助都会很棒, 谢谢
答案 0 :(得分:0)
您需要TagName
Debug.Print ie.document.getElementsByTagName("tr")(7).innerText
我虽然获得了验证码,所以我怀疑您是否可以通过这种方式完成此任务。硒和IE似乎都触发了验证码,至少对我而言。
如果不输入验证码,我将按如下方式重新编写脚本(也许通过循环来确保存在tr元素):
Option Explicit
Public Sub GetLastChangeDate()
Dim ie As New SHDocVw.InternetExplorer, doc As HTMLDocument
Const URL = "gepir.gs1.org/index.php/search-by-gtin"
With ie
.Visible = True
.navigate URL
While .Busy Or .readyState < 4: DoEvents: Wend
Set doc = .document
Debug.Print .LocationName, .LocationURL
doc.getElementById("keyValue").Value = "685387379712"
doc.getElementById("submit-button").Click
While .Busy Or .readyState < 4: DoEvents: Wend
Debug.Print .document.getElementsByTagName("tr")(7).innerText
End With
End Sub