Now this one is more efficient than previous one. Very Fast.
Before running this code please refer.
Microsoft Microsoft Winhttp Services
and
Microsoft Html object lib in the VB editor>>tools>>references
Sub WebScrapper()
Dim Req As New WinHttpRequest
Dim Doc As New HTMLDocument
Dim tbl As HTMLTable
Dim tblRows As IHTMLElementCollection
Dim Ro As HTMLTableRow
Dim Ce As HTMLTableCell
URL = "http://financials.morningstar.com/valuation/valuation-history.action?&t=XNAS:INTC®ion=usa&culture=en-US&cur=&type=price-earnings&_=1429984664101"
With Req
.Open "GET", URL, False
.setRequestHeader "User-Agent", "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
.send
Doc.body.innerHTML = .responseText
End With
Stop
Set tbl = Doc.getElementsByTagName("tbody")(0)
Set tblRows = tbl.getElementsByTagName("tr")
For Each Ro In tblRows
r = r + 1
For Each Ce In Ro.Cells
c = c + 1
Cells(r, c) = Ce.innerText
Next
c = 0
Next
MsgBox "Table Scrapped", vbInformation
End Sub
Bookmarks