为了让没有注册本论坛的兄弟们方便,还是把代码贴出来:
Sub 查找标签innerText()
Dim arr
[a1:cm1] = Split("标签号,a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big,blockquote,body,br,button,caption,center,cite,code,col,colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,frameset,head,h1,h2,h3,h4,h5,h6,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,q,s,samp,script,select,small,span,strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var", ",")
Application.ScreenUpdating = False
Cells.EntireColumn.Hidden = False
s = 0
For p = 1 To 91
If Cells(2, p) > s Then s = Cells(2, p)
Next p
Rows("2:" & s + 3).Delete Shift:=xlUp
arr = Range(Cells(1, 2), Cells(1, 91))
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://de.yusuan.com/index.html"
Do Until .ReadyState = 4
DoEvents
Loop
For p = 1 To 90
str1 = arr(1, p)
Set r = .Document.All.tags(str1)
Cells(2, p + 1) = r.Length
For i = 0 To r.Length - 1 '标签的个数
Cells(i + 3, 1) = i
Cells(i + 3, p + 1) = r(i).innerText '把第i个标签的内容写入第i+3行,2 * p列
Next i
Next p
.Quit
End With
Columns("A:A").Columns.AutoFit
Rows("1:2").Columns.AutoFit
For p = 1 To 91
If Cells(2, p + 1) = 0 Then Columns(p + 1).EntireColumn.Hidden = True
Next p
Application.ScreenUpdating = True
MsgBox "ok"
End Sub
还有查找标签的name的:
Sub 查找标签name()
Dim arr
On Error Resume Next
[a1:cm1] = Split("标签号,a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big,blockquote,body,br,button,caption,center,cite,code,col,colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,frameset,head,h1,h2,h3,h4,h5,h6,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,q,s,samp,script,select,small,span,strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var", ",")
Application.ScreenUpdating = False
Cells.EntireColumn.Hidden = False
s = 0
For p = 1 To 91
If Cells(2, p) > s Then s = Cells(2, p)
Next p
Rows("2:" & s + 3).Delete Shift:=xlUp
arr = Range(Cells(1, 2), Cells(1, 91))
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://de.yusuan.com/index.html"
Do Until .ReadyState = 4
DoEvents
Loop
For p = 1 To 90
str1 = arr(1, p)
Set r = .Document.All.tags(str1)
Cells(2, p + 1) = r.Length
For i = 0 To r.Length - 1 '标签的个数
Cells(i + 3, 1) = i
Cells(i + 3, p + 1) = r(i).Name '把第i个标签名写入第i+3行,2 * p列
Next i
Next p
.Quit
End With
Columns("A:A").Columns.AutoFit
Rows("1:2").Columns.AutoFit
For p = 1 To 91
If Cells(2, p + 1) = 0 Then Columns(p + 1).EntireColumn.Hidden = True
Next p
Application.ScreenUpdating = True
MsgBox "ok"
End Sub
|