YouTube - extract data with VBA

viktor4e

New Member
Joined
Jun 30, 2014
Messages
16
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!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

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