YouTube Comments to CSV (✓ Official YouTube API, ✘ scraping) w Python

preview_player
Показать описание
YouTube comment scraping (or using web-scraping on YouTube channel) is against YouTube's fair use policy so in this series we'll look at extracting YouTube comments for any channel or video using the official YouTube API instead. Specifically, we will use the CommentThreads resource from the API to collect all youtube comments, including replies, on a specified video or channel and write Python code to export that into a nice CSV.

Timestamps:
00:00 What we're building: Youtube comment scraper
01:54 Youtube Data API Explorer
14:03 YouTube comment scraper setup
25:22 Running our youtube scraper!
28:25 Turning unstructured json to structured list for csv creation
40:46 Creating csv of youtube comments
50:17 Collection more youtube comments by pagination (nextPageToken)

If you enjoy API-related and API development content, let me know in the comments section. Subscribe to the channel and share the video with a friend!
Рекомендации по теме
Комментарии
Автор

Great tutorial. Very well discussed on all components. Easy to navigate as well

AsianBoi
Автор

Hi, How do I make a column in the CSV that states whether or not the comment is a spam or not?

SZakiabba
Автор

Hi Thank you for this tutorial. I have a question tho can you somehow collect emails from comments in a youtube video?

reato
Автор

Thanks for the video.
A query : how do we keep track of the quota? Does the API page offer a stat?

soumilyade
Автор

Hi! Thank you for this clear documentation and tutorial. This was my first project working with Python and Youtube API. I am very happy to see the comments in neat CSV files. 😊 I have a short question though. Do you know why it is not possible to get all the comments although we use NextPageToken? The video I am working with has 2805 results, but I only receive 1652. Do you have any idea why that is and maybe have any ideas for a solution? Thank you so much.

didem_le
Автор

Does this method also work for scraping comments under the community tab?

allcreatures
Автор

I tried this, and the resulting size of the dataset is much larger than the count in public video. Like on one video I tried, it has around 2k comments, shown as the count in the comment section, and the size of the dataset is around 120k. I'm wondering if the API also extracts blocked comments like spams (I did see multitudes of duplicate obvious-looking spam when skimming), or is the count in the comment section wrong? If it does count is there a way for extracting comments that is available in public?

rendon
Автор

Is there a way for the csv file to be sorted by Top Comments instead of newest first the same way how they are displayed in Youtube where also the replies of the comments are nested?

Edit: Thank you for the video. Still learning and I'm actually struggling since it seems not all comments or replies are showing.

AisIceEyesYT
Автор

What "IDE" are you using and where can i get it from?

Jon_TheBeloved
Автор

Hello, this was a clear tutorial and everything work perfectly as explained .. I need you advise on how I can get an email Id of comment

DavidJackson-vz
Автор

Hey this video is amazing! May I kindly ask how to get comments for a youtube video where there are about 54000 comments, as I tried to follow the tuition but it only processes 44602 comments and then stop there.

yichongchen
Автор

I want to contact you about some help with setting up mrkl and langchain but I cannot find a email for u..

dedefrench
Автор

Hi Samuel, first of all thanks for the video, it was very helpful! I just have one problem as I am only getting replies but not the comments with no parent id. Do you know what might be happening? I saw all your explanation and Github code and everything seems to be the same.
Thank you!

wuarkerz
Автор

how i can get scraping over 10k comments in html formart?

hatubadhan
Автор

Hi, is it legal to scrap youtube comments ? Thanks

othmanebelaidi
Автор

Great video but Chrome screen distract me when you python code.

mando
Автор

Feels like a nightmare trying to get this all setup. Thanks though!

roberttyler
Автор

ffs if you cant speak proper english accent then atleast add subtitles too.😐🙏 also the browser window is too tiny

AwaisNaeem-poty
Автор

Very good "how to" legit video on leveraging YouTube dev tools, much appreciated.
I looked in the available areas to query, and could not find "streamed chat comments". Do you know if there is a hook or method to query a streamed/streaming YT video Chat comments?
Thank you for sharing your expertise - very concise, easy to follow along.
[edit] I may have located it under the Videos overview:

The ID of the currently active live chat attached to this video. This field is filled only if the video is a currently live broadcast that has live chat. Once the broadcast transitions to complete this field will be removed and the live chat closed down. For persistent broadcasts that live chat id will no longer be tied to this video but rather to the new video being displayed at the persistent page.

truegret