我有一个问题。我使用过去15天的日期范围从网站上提取数据。当我从日期和日期进入时,我获得了6个列的数据,我需要将其复制到Excel工作表数据中。下面是我尝试但无法执行的代码。请帮忙。
Sub scrapdata()
Dim eRow As Long
Dim ele As Object
Dim objIE
Set sht = Sheets("Data")
RowCount = 1
sht.Range("A" & RowCount) = "Product(s)"
sht.Range("B" & RowCount) = "Manufacturer"
sht.Range("C" & RowCount) = "NOC with conditions"
sht.Range("D" & RowCount) = "Notice of Compliance date"
sht.Range("E" & RowCount) = "Medicinal ingredient(s)"
sht.Range("F" & RowCount) = "DIN(s)"
eRow = sht.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Set objIE = CreateObject("InternetExplorer.Application")
mynocFromDate = InputBox("enter from date eg.2016-10-01")
mynocToDate = InputBox("enter to date eg.2016-10-05")
With objIE
.Visible = True
.Navigate "https://health-products.canada.ca/noc-ac/index-eng.jsp"
Do While .Busy Or .readyState <> 4
DoEvents
Loop
setcol -sm - 6 = .document.getElementsByname("q")
col-sm-6.Item(o).Value = nocFromDate
setcol -sm - 6 = .document.getElementsByname("nocToDate")
col -sm - 6.Item(o).Value = nocToDate
.document.getElementById("mrgn-tp-md").Click
For Each ele In .document.all
Select Case ele.classname
Case "table-responsive"
RowCount = RowCount + 1
Case "Product"
sht.Range("A" & RowCount) = ele.innerText
Case "Manufacturer"
sht.Range("B" & RowCount) = ele.innerText
Case "NOC with conditions"
sht.Range("C" & RowCount) = ele.innerText
Case "Notice of Compliance date"
sht.Range("D" & RowCount) = ele.innerText
Case "Medicinal ingredient(s)"
sht.Range("E" & RowCount) = ele.innerText
Case "DIN(s)"
sht.Range("F" & RowCount) = ele.innerTex
End Select
Next
End With
Set objIE = Nothing
End Sub