Trying to fetch Youtube Trending videos name and links using Excel VBA

gauravkm

New Member
Joined
Apr 17, 2019
Messages
1
I'm trying to fetch Youtube Trending videos into excel sheet with Title and video links. But my code is not working. I do not know whether there is something wrong with my code or the trending page. This is code from where i am trying to video the data

HTML:
    VIDEO TITLE

When i run the code. It just load the page and does nothing. It does not even show any error. I tried fetching data "getElementbyID" as well as with "getElementsByClassName".

Here is the screenshot from where i am trying to fetch the data.

IYQ9QkC.png


Here the code that i have been trying:
Code:
Sub YOUTUBETREND()

Dim objIE As SHDocVw.InternetExplorer
Dim aEle As HTMLLinkElement
Dim y As Integer
Dim result As String 


Set objIE = New InternetExplorer


objIE.Visible = True


objIE.navigate "https://www.youtube.com/feed/trending/"


Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop


y = 2


For Each aEle In objIE.document.getElementsByClassName("yt-simple-endpoint")


    result = aEle
    Sheets("Sheet1").Range("C" & y).Value = result

    
    Sheets("Sheet1").Range("D" & y).Value = aEle.innerText
    Debug.Print aEle.innerText

    y = y + 1

Next
objIE.Quit<code></code>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,215,136
Messages
6,123,247
Members
449,093
Latest member
Vincent Khandagale

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