怎么获取webbrowser登录的网页中的textbox的ID
怎么获取webbrowser登录的网页中的textbox的ID
1、查看网页源代码
2、抓包,检查post数据也能发现的。这个应该是最准确的。
Private Sub Form_Load() WebBrowser1.Silent = True WebBrowser1.Navigate "http://venman." End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim doc Dim tg Set doc = WebBrowser1.Document For i = 0 To doc.All.length - 1 '扫描a标签元素 If (LCase(doc.All(i).tagname)) = "a" Then Debug.Print i & "." & "Class名称:" & doc.All(i).className & " " & "元素id:" & doc.All(i).id & " " & "href值:" & doc.All(i).href & " " _ & "target值:" & doc.All(i).Target & " " & "标签值:" & doc.All(i).innerText End If '扫描Input元素 If (LCase(doc.All(i).tagname)) = "Input" Then Debug.Print i & "." & "Input元素名称:" & doc.All(i).id & " " & "value值:" & doc.All(i).Value & " " & "placeholder值:" & doc.All(i).placeholder End If '扫描img元素 If (LCase(doc.All(i).tagname)) = "img" Then Debug.Print i & "." & "img元素id:" & doc.All(i).id & " " & "alt值:" & doc.All(i).alt End If '扫描textarea元素 If (LCase(doc.All(i).tagname)) = "textarea" Then Debug.Print i & "." & "textarea元素名称:" & doc.All(i).id & " " & "value值:" & doc.All(i).Value & " " End If '扫描form元素 If (LCase(doc.All(i).tagname)) = "form" Then Debug.Print i & "." & "form元素名称:" & doc.All(i).id End If Next i End Sub