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
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.
Here the code that i have been trying:
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.
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>