Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Instagram Profile Scraper
# Instagram Profile Scraper
by SoClose Society — https://soclose.co
Digital solutions & software development studio.

Expand All @@ -22,14 +21,13 @@
DISCLAIMER: This tool is provided for educational purposes only.
Scraping Instagram may violate their Terms of Service.
Use responsibly and at your own risk.
"""

import csv
import logging
import os
import random
import sys
import time
time
from pathlib import Path

from bs4 import BeautifulSoup
Expand Down Expand Up @@ -61,7 +59,6 @@
SCROLL_AMOUNT = 600 # Pixels to scroll down per iteration
SAVE_INTERVAL = 50 # Save to CSV every N iterations


# ---------------------------------------------------------------------------
# Helper Functions
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -122,7 +119,6 @@ def login(driver: webdriver.Chrome, username: str, password: str) -> bool:
logger.info("Login successful.")
return True


EXCLUDED_PATHS = {
"/explore/", "/accounts/", "/reels/", "/stories/", "/direct/",
"/directory/", "/developer/", "/about/", "/legal/", "/privacy/",
Expand Down Expand Up @@ -199,7 +195,6 @@ def scrape_profiles(driver: webdriver.Chrome, output_file: Path) -> list[str]:

return sorted(all_links)


# ---------------------------------------------------------------------------
# Main Entry Point
# ---------------------------------------------------------------------------
Expand All @@ -221,7 +216,7 @@ def main() -> None:
logger.error("Could not log in. Exiting.")
return

input("\nNavigate to the page you want to scrape, then press ENTER to start...")
input(\"Navigate to the page you want to scrape, then press ENTER to start...\")

links = scrape_profiles(driver, output_file)
save_to_csv(links, output_file)
Expand All @@ -235,6 +230,5 @@ def main() -> None:
driver.quit()
logger.info("Browser closed.")


if __name__ == "__main__":
main()