Scrap data from website..

reachmanoj27

New Member
Joined
Aug 31, 2016
Messages
6
<code>I am pulling the data which is on table format from a website based on
from date, I am giving the date by using input box so that it goes and
sit in the form for from date box which is in website and search for
results but not unfortunately the date which i am giving is not sitting
in from date box, I am getting the blank results. Could you please help
on this? thank You in advance

Option Explicit
Sub extractTablesData()

Dim IE As Object, obj As Object
Dim myfromdate As String
Dim r As Integer, c As Integer, t As Integer
Dim elemCollection As Object


Set IE = CreateObject("InternetExplorer.Application")


myfromdate = InputBox("Enter From date format YYYY-MM-DD")

With IE

.Visible = True
.navigate ("https://health-products.canada.ca/noc-ac/index-eng.jsp")


While IE.ReadyState <> 4
DoEvents
Wend


For Each obj In IE.Document.getElementsByName("nocFromdate")

If obj.innerText = myfromdate Then

obj.Selected = True

End If

Next obj



IE.Document.getElementsByName("action").Item.Click


Do While IE.busy: DoEvents: Loop


worksheets("Sheet1").Range("A:Z").ClearContents

Set elemCollection = IE.Document.getElementsByTagName("TABLE")

For t = 0 To (elemCollection.Length)

For r = 0 To (elemCollection(t).Rows.Length)
For c = 0 To (elemCollection(t).Rows(r).Cells.Length)
worksheets("Sheet1").Cells(r + 1, c + 1) = elemCollection(t).Rows(r).Cells(c).innerText
Next c
Next r
Next t

End With

Set IE = Nothing

End Sub</code>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top