Skip to content
Advertisement

Getting The Title of a Youtube Video Using Python/Selenium

I am trying to scrape the title of a youtube video (https://www.youtube.com/watch?v=MBBtxuHoV_g) with the following python script. When I run my current code:

JavaScript

The output gives me

JavaScript

How do I change my code so it just returns the title of the video? Any help is much appreciated!

Advertisement

Answer

If you only want to get that title without using any hardcoded index then the following should work:

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement