Selenium and youtube

LisaGreen
5StarLounger
Posts: 964
Joined: 08 Nov 2012, 17:54

Selenium and youtube

Post by LisaGreen »

Hello all you selenium people.

Is it possible to use selenium to ..

1.. Capture/download the Transcription of a youtube video.
2.. Capture/download the Chat of a youtube video.
3.. Get the playlist of all videos on a channel.

TIA
Lisa

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Selenium and youtube

Post by YasserKhalil »

Hello
I think it is more convenient for your needs to use programming language as python as there are ready packages used for such stuff.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15595
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Selenium and youtube

Post by ChrisGreaves »

LisaGreen wrote:
09 Nov 2021, 16:08
1.. Capture/download the Transcription of a youtube video.
2.. Capture/download the Chat of a youtube video.
3.. Get the playlist of all videos on a channel.
Hi Lisa
It all depends on what you mean by “Transcription”, “Chat” and “Capture/download”. :evilgrin:

As an example, from this YouTube page (https://www.youtube.com/watch?v=p5kY6KUuR0w) I can easily grab the entire text of the web page (see below)

If you want to know how many people have viewed the video (21,669 as I type), we can right-click on that number, choose “Inspect” and then “Edit as html” and so capture this:-
<span class="view-count style-scope ytd-video-view-count-renderer">21,669 views</span>
which tells us the class=, (and usually id=, name= etc) of that particular element. That makes it easy to grab specific data from the site (but see my exercise with reconciling eight financial accounts each month)

Selenium allows us to program a mouse-click (or the <enter> key) so on Sandra&Tim’s channel we should be able to program a click on the “playlists” tab and then program a click on the “View Full Playlist” command and THEN harvest the results.

Below: In one of my Selenium aps I send a search key to eight search engines and grab the pages of hits from all eight engines in a single MSWord document, typically 30 to 50 pages of Word document. I then search for all sorts of contact details (telephone, PO Box number, web url, email etc) and return my best bet of the most appropriate item (or sometimes the two best bets ...) That is not the same as using this “element-specific” approach, but it works.

If you want to set me a specific exercise (I’m in a good mood because I managed to raise my wind turbine mast this afternoon), send me a URL (PM if it is an embarrassing URL hah hah) and perhaps a couple of screen shots identifying what you would like to capture.

[Later] I can't see why, if a Download option is available, one couldn't issue a programmed mouse-click on the <Download> button, download the MP4, and then invoke "Free M4a to MP3 Converter" to convert the MP4 files to MP3. That would solve my boring-and-repetive (but very rewarding) weekly task of continuing to attend the St Andrew's (Toronto) Friday free lunchtime concerts at a distance.

West Bishes!
Chris
There's nothing heavier than an empty water bottle

LisaGreen
5StarLounger
Posts: 964
Joined: 08 Nov 2012, 17:54

Re: Selenium and youtube

Post by LisaGreen »

YAY for you getting your turbine up Chris!!!

As specific as I can be....
On the page..
https://www.youtube.com/watch?v=vWNfQ9DoZjw

To the right of the normal view replay of the video, There is a chat listing.

That's what I want.




TIA
Lisa

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15595
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Selenium and youtube

Post by ChrisGreaves »

LisaGreen wrote:
12 Nov 2021, 18:03
YAY for you getting your turbine up Chris!
I haven't been able to get it up yet, Lisa; it is far too cold (and windy). Maybe tomorrow.
Untitled.png
So:-
(1) you don't want the little drop-down arrow
(2) you don't want the bits I have crossed out
(3) you do want the bit I have circled which is, as I type, void; presumably because It is not yet Sunday 8pm where Luther does his stuff.
Is that the bit you want?
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15595
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Selenium and youtube

Post by ChrisGreaves »

LisaGreen wrote:
09 Nov 2021, 16:08
Is it possible to use selenium to ..
Hi Lisa,
The enclosed VBA code (attached document) should get you to the point where the YouTube video page opens up. I believe that I can program a click on the play button (which starts up a Bill-Bailey look-alike and opens up the chat box).
Please be aware that I am very new to Selenium and Web Elements". I come across a new hurdle every day and sometimes learn how to leap over (or past it) after a few days research and thought.
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

LisaGreen
5StarLounger
Posts: 964
Joined: 08 Nov 2012, 17:54

Re: Selenium and youtube

Post by LisaGreen »

Thank you Chris!!

I will go through this with a fine comb!!

Lisa