dushyantgupta111
New Member
- Joined
- Sep 16, 2015
- Messages
- 4
Hi all,
I am trying to scrap list of VBA course items given at the right pane of the following link "www.tutorialspoint.com//vba/index.htm"
But I am unable to scrap list due to some error.
the code I have written is:
I am trying to scrap list of VBA course items given at the right pane of the following link "www.tutorialspoint.com//vba/index.htm"
But I am unable to scrap list due to some error.
the code I have written is:
Code:
[COLOR=#E56717][B]Sub[/B][/COLOR] tutorailpointsscrap()
[COLOR=#151B8D][B]Dim[/B][/COLOR] ie [COLOR=#151B8D][B]As[/B][/COLOR] InternetExplorer
[COLOR=#151B8D][B]Set[/B][/COLOR] ie = [COLOR=#E56717][B]New[/B][/COLOR] InternetExplorer
[COLOR=#8D38C9][B]With[/B][/COLOR] ie
.navigate [COLOR=#800000]"https://www.tutorialspoint.com//vba/index.htm"[/COLOR]
.Visible = [COLOR=#00C2FF][B]True[/B][/COLOR]
[COLOR=#8D38C9][B]Do[/B][/COLOR] [COLOR=#8D38C9][B]While[/B][/COLOR] ie.readyState <> READYSTATE_COMPLETE
[COLOR=#8D38C9][B]DoEvents[/B][/COLOR]
[COLOR=#8D38C9][B]Loop[/B][/COLOR]
[COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#8D38C9][B]With[/B][/COLOR]
[COLOR=#151B8D][B]Dim[/B][/COLOR] html [COLOR=#151B8D][B]As[/B][/COLOR] HTMLDocument
[COLOR=#151B8D][B]Set[/B][/COLOR] html = ie.document
[COLOR=#151B8D][B]Dim[/B][/COLOR] ele [COLOR=#151B8D][B]As[/B][/COLOR] IHTMLElement
[COLOR=#151B8D][B]Dim[/B][/COLOR] lists [COLOR=#151B8D][B]As[/B][/COLOR] IHTMLElementCollection
[COLOR=#151B8D][B]Dim[/B][/COLOR] row [COLOR=#151B8D][B]As[/B][/COLOR] [COLOR=#F660AB][B]Long[/B][/COLOR]
[COLOR=#151B8D][B]Set[/B][/COLOR] ele = html.getElementsByClassName([COLOR=#800000]"nav nav-list primary left-menu"[/COLOR])
[COLOR=#151B8D][B]Set[/B][/COLOR] lists = ele.getElementsByTagName([COLOR=#800000]"li"[/COLOR])
row = 1
[COLOR=#8D38C9][B]For[/B][/COLOR] [COLOR=#8D38C9][B]Each[/B][/COLOR] li [COLOR=#8D38C9][B]In[/B][/COLOR] lists
Cells(row, 1) = li.innerText
row = row + 1
[COLOR=#8D38C9][B]Next[/B][/COLOR]
ie.Quit
[COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#E56717][B]Sub[/B][/COLOR]