/Instagram-Comments-Scraper

Instagram comment scraper using python and selenium. Save the comments into excel.

Primary LanguagePythonMIT LicenseMIT

Instagram Comments Scraper

forked from AgiMaulana

Install dependencies

pip install -r requirements.txt # or conda install

Install Chrome Web Driver

Download latest Chrome web driver from https://sites.google.com/a/chromium.org/chromedriver/downloads

Or if you on Linux/Ubuntu
wget https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip

Extract the binary then move to /usr/local/bin/
sudo mv chromedriver /usr/local/bin/chromedriver
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver

Ref:/usr/bin vs. /usr/local/bin

Run

python scraper.py post-url total-load-more-click
Change the URL with your post target
Example :
python scraper.py https://www.instagram.com/p/BqUfulwH6O4/ 5

License

This project is under the MIT License

Other reference

  • Youtube: Load more comments
  • Type this in the Chrome Console and see the Network >> Preview >> "?query_hash" (XHR)
    • document.querySelector("#react-root > section > main > div > div > article > div.eo2As > div.EtaWk > ul > li > div > button > span").click()
  • Network >> Header >> Query Parameters >> "after"
    • variables: {"shortcode":"CAbZ2X","first":12,"after":"QRXWlZJR01RY3YzbVcyTkRFc0dUMFY3blBvN24xaHhkTDR="}