标签:
vb中包括text、button
Private Sub Form_Load() WebBrowser1.Navigate "localhost/getwebtable/" End Sub Private Sub Command1_Click() Set vDos = WebBrowser1.Document.getElementsByTagName("td") Text1.Text = vDos(1).innerText Text2.Text = vDos(3).innerText Text3.Text = vDos(5).innerText Dim I As Integer Set xlsApp = Excel.Application xlsApp.Visible = False Set xlsBook = xlsApp.Workbooks.Open("..\Desktop\most\a.xls") I = 1 Do While xlsApp.Sheets(1).cells(I, 1) <> "" I = I + 1 Loop xlsApp.Sheets(1).cells(I, 1) = Text1.Text xlsApp.Sheets(1).cells(I, 2) = Text2.Text xlsApp.Sheets(1).cells(I, 3) = Text3.Text xlsBook.Close (True) xlsApp.Quit Set xlsApp = Nothing MsgBox "数据写入成功!" End Sub
我觉得不好的地方就是要数是第几个td,如果网页中有很多table,那么td的个数容易搞混。第一个td为0;
标签:
原文地址:http://www.cnblogs.com/cdlinux/p/4328653.html