def like_comment_photos(instagram: Instagram, utils: Utils, photos: list, user: str, comment: bool = True) -> None: liked = 0 commented = 0 if photos: for photo in photos: instagram.like_photo(photo) liked += 1 utils.insert_photos(photo, instagram.username) time.sleep(3) comment_true = random.randint(1, 4) if comment and (comment_true == 1): instagram.comment(config.COMMENTS, photo) seconds = random.randint(3, 10) time.sleep(seconds) commented += 1 utils.insert_followed_or_visited_account("Visited", user, instagram.username, liked) conn.commit() print(f"You commented {commented} and liked {liked} photos on {user}") else: utils.insert_followed_or_visited_account("Visited", user, instagram.username, 0)
from instagram import Instagram from selenium import webdriver from time import sleep from comment_list import COMMENT_LIST URL = "https://www.instagram.com/p/CCZfJc9jbFz/" USERNAME = "******" PASSWORD = "******" COMMENT_NUMBER = 1000 COMMENT_LIST = COMMENT_LIST USER_NUMBER_PER_COMMENT = 2 DRIVER = webdriver.Chrome() INSTAGRAM = Instagram(DRIVER, URL) INSTAGRAM.navigate() INSTAGRAM.login(USERNAME, PASSWORD) INSTAGRAM.comment(COMMENT_LIST, USER_NUMBER_PER_COMMENT, COMMENT_NUMBER)