How to scrape YouTube video data
If you're conducting a content audit and have been handed a list of 1,000 YouTube video URLs, you might currently be in a bit of a state.
But because computers are amazing, you need not fret beyond booting up Sheets in Google Drive and hammering in a few keystrokes.
- Create a new sheet
- Add your headers in row 1: any or all from YouTube URL, username (only if you're auditing multiple channels), title, description, date published, views, likes.
- Add a single YouTube URL into A2
Append to the formula bar any of the following strings depending on which data you need, under the headings corresponding to the information required (as shown below):
User name
=IMPORTXML(A2,"//*[@id='watch7-user-header']/div/a")
Title
=IMPORTXML(A2,"//*[@id='eow-title']")
Description
=IMPORTXML(A2,"//*[@id='eow-description']")
Date Published
=IMPORTXML(A2,"//*[@id='watch-uploader-info']/strong")
Views
=IMPORTXML(A2,"//*[@id='watch7-views-info']/div[1]")
Likes
=IMPORTXML(A2,"//*[@id='watch8-sentiment-actions']/span/span[1]/button/span")
Assuming you've added a whole load of additional YouTube URLs underneath A2, all you need to do is drag the box outline of the data you have just generated, down to the bottom of the list, and Google will action those formulas on every single one of those goddamn videos.
It's super slick, super simple - and will save you a ton of time.
You are WELCOME!