Skip to content

Instantly share code, notes, and snippets.

Mon 07 10:33:16 [INFO] Liked IgPost(shortcode='CEoZFnIoAoY', caption='nick-friends!', like_count=100, comment_count=0, taken_at_datetime_utc=datetime.datetime(2020, 9, 2, 10, 39, 53), is_video=False, caption_tags=set())
Mon 07 10:33:20 [INFO] Liked IgPost(shortcode='CEzzI-xDVdm', caption='', like_count=124, comment_count=0, taken_at_datetime_utc=datetime.datetime(2020, 9, 6, 20, 59, 11), is_video=False, caption_tags=set())
Mon 07 10:33:24 [INFO] Liked IgPost(shortcode='CEpRyg4hRFS', caption='remember when i used to hage a max (demi’s bodyguard not fiancé) fan account? i think it got deleted 😔', like_count=149, comment_count=0, taken_at_datetime_utc=datetime.datetime(2020, 9, 2, 18, 55, 21), is_video=False, caption_tags=set())
Mon 07 10:33:31 [INFO] Liked IgPost(shortcode='CE1MouRlAMt', caption='i remember when these photos came out... she looks so good — @iamhalsey', like_count=81, comment_count=0, taken_at_datetime_utc=datetime.datetime(2020, 9, 7, 10, 1, 13), is_video=False, caption_tags=set())
Mon 07 10:33
from bot import AutoLikeBot
from filter import MyCustomFilter
from strategy import RunForeverWithBreaks
...
if __name__ == '__main__':
with AutoLikeBot(configure_chrome_driver(),
post_filter=MyCustomFilter(ignore_tags=config.IGNORE_TAGS),
running_strategy=RunForeverWithBreaks(200)) as bot:
@dev4Fun
dev4Fun / bot.py
Last active September 10, 2020 03:28
def __enter__(self):
if not config.SKIP_LOGIN:
self.log_in()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.driver.quit()
logger.info(post_tracker.stats)
return None
@dev4Fun
dev4Fun / bot.py
Created September 10, 2020 03:27
def like_from_explore(self):
max_id = 0
while True:
try:
posts = self.fetch_posts_from_explore(max_id)
except TimeoutException:
continue
random.shuffle(posts)
for post in posts:
@dev4Fun
dev4Fun / bot.py
Created September 10, 2020 03:27
def like_post(self, post):
self.open_and_switch_to_tab(post.post_link)
try:
self.wait_until(ec.presence_of_element_located((By.CLASS_NAME, 'fr66n')))
self.driver.find_element_by_class_name('fr66n').click()
post_tracker.liked_post(post)
logger.info(f"Liked {post}")
rand_wait_sec()
return True
import random
from time import sleep
def rand_wait_min(a=None, b=None):
a = a if not a else a * 60
b = b if not b else b * 60
rand_wait_sec(a, b)
import logging
from abc import abstractmethod
from tracker import post_tracker
from utils import rand_wait_min
logger = logging.getLogger()
class BotRunningStrategy:
from datetime import timedelta, datetime
from typing import Collection
from post_parser import IgPost
from tracker import post_tracker
class PostFilter:
def __init__(self, like_limit=150, like_videos=True, ignore_tags: Collection = frozenset(),
max_time_difference=timedelta(days=7)):
from collections import defaultdict
class PostStats:
def __init__(self):
self.liked_count = 0
self.skipped_count = 0
class _PostTracker:
import json
from dataclasses import dataclass, field
from datetime import datetime
from typing import Set
@dataclass
class IgPost:
post_id: str = field(repr=False)
shortcode: str