This project is a collection of python classes that can be used to scrape comments from Instagram and Youtube, translate them to English, and perform sentiment analysis on them. The results can then be exported to a CSV file.
- Clone the repository.
- Open a terminal in the project folder.
- Create a virtual environment in the project folder.
- Activate the virtual environment.
- Install the required packages using the requirements.txt file.
- Create a
settings.py
file in the project folder (example below). - Use the classes in the project folder.
For example:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
touch settings.py
python youtube-analysis.py
# settings.py
# no credentials needed scraping youtube comments
INSTAGRAM_USERNAME = "YOUR_USERNAME"
INSTAGRAM_PASSWORD = "YOUR_PASSWORD"
INSTAGRAM_CONTENT_URL = "POST_URL"
YOUTUBE_CONTENT_URL = "VIDEO_URL"
BaseCommentScraper (abstract class for child scraper classes)
InstagramCommentScraper (login credentials required)
YoutubeCommentScraper (no credentials required)
TextTranslator (no credentials required)
SentimentAnalysis (no credentials required)
CSVExporter (no credentials required)
The InstagramCommentScraper class requires login credentials to work. You can create a new Instagram account and use it to scrape comments. The account will be banned if you use it to scrape too many comments in a short period of time. You can also use your own account, but it is not recommended. The YoutubeCommentScraper class does not require login credentials.
https://github.com/adw0rd/instagrapi for InstagramCommentScraper
https://github.com/alexmercerind/youtube-search-python for YoutubeCommentScraper
https://github.com/nidhaloff/deep-translator for TextTranslator
https://github.com/sloria/TextBlob for SentimentAnalysis
https://github.com/fnielsen/afinn for SentimentAnalysis