diff --git a/main.py b/main.py index 8ec29cc..98a4a4d 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,4 @@ -""" -Instagram Profile Scraper +# Instagram Profile Scraper by SoClose Society — https://soclose.co Digital solutions & software development studio. @@ -12,24 +11,19 @@ Usage: python main.py -Environment Variables: - INSTA_USERNAME - Instagram username or email - INSTA_PASSWORD - Instagram password - License: MIT — See LICENSE file for details. Contact: contact@soclose.co 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 @@ -61,12 +55,12 @@ SCROLL_AMOUNT = 600 # Pixels to scroll down per iteration SAVE_INTERVAL = 50 # Save to CSV every N iterations - # --------------------------------------------------------------------------- # Helper Functions # --------------------------------------------------------------------------- + def create_driver() -> webdriver.Chrome: """Create and configure a Chrome WebDriver instance.""" options = webdriver.ChromeOptions() @@ -122,7 +116,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/", @@ -199,7 +192,6 @@ def scrape_profiles(driver: webdriver.Chrome, output_file: Path) -> list[str]: return sorted(all_links) - # --------------------------------------------------------------------------- # Main Entry Point # --------------------------------------------------------------------------- @@ -221,7 +213,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) @@ -235,6 +227,5 @@ def main() -> None: driver.quit() logger.info("Browser closed.") - if __name__ == "__main__": - main() + main() \ No newline at end of file