This python script allows you to scrap all the comments given a youtube video link and save them into a csv
file.
You will need to install Postman in order to make use of this app.
To install dependencies, run:
pip install -r requirements.txt
Follow the instructions in this link to obtain the API key.
Specifically, in Google API Console
, navigate to YouTube Data API v3
and in the credential
tab create an API key.
Make a .env
file as follows:
cp .env.example .env
and fill in your API key in the file.
set FLASK_APP=api.py
flask run
And now the app is listening on http://127.0.0.1:5000/.
Now, open a new tab and select POST
method on the address: http://127.0.0.1:5000/getResult
On the tab below, choose Body
and select raw
in JSON
format.
Paste the following:
{
"url": "https://www.youtube.com/watch?v=kuhhT_cBtFU&t=2s&ab_channel=CNN"
}
And hit Send
button.
Now, the csv
file should be in the folder of ./data/
.
Enjoy!