Hi everyone,
I have been working on a code which I want to use to extract data from YouTube music video channels (such as: https://www.youtube.com/user/RihannaVEVO/about). The data I would like to extract is:
1. Number of subscribers
2. Number of views
In the code below, I have entered a number of these web site links in column K and I want the macro to loop through each and populate columns A and B with the data. This is the code that I currently have but does not work:
Sub YouTube()
Application.ScreenUpdating = False
Dim I As Integer
Dim ie As New InternetExplorer
Dim doc As HTMLDocument
Dim x As String
ie.Visible = False
For I = 1 To 1
ie.Navigate Cells(I, 11).Value
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
With doc
x = doc.getElementById("page-container")(1).PreviousSibling.getElementsByClass("about-stats")(0).innerText
Cells(I, 1).Value = x
End With
Next I
ie.Quit
Application.ScreenUpdating = True
End Sub
Any help is much appreciated!
I have been working on a code which I want to use to extract data from YouTube music video channels (such as: https://www.youtube.com/user/RihannaVEVO/about). The data I would like to extract is:
1. Number of subscribers
2. Number of views
In the code below, I have entered a number of these web site links in column K and I want the macro to loop through each and populate columns A and B with the data. This is the code that I currently have but does not work:
Sub YouTube()
Application.ScreenUpdating = False
Dim I As Integer
Dim ie As New InternetExplorer
Dim doc As HTMLDocument
Dim x As String
ie.Visible = False
For I = 1 To 1
ie.Navigate Cells(I, 11).Value
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
With doc
x = doc.getElementById("page-container")(1).PreviousSibling.getElementsByClass("about-stats")(0).innerText
Cells(I, 1).Value = x
End With
Next I
ie.Quit
Application.ScreenUpdating = True
End Sub
Any help is much appreciated!