def test_update_tag(login, password, name): agent = AgentAccount(login, password) tag = Tag(name) data = agent.update(tag) Tag.clear_cache()
def test_get_stories(login, password): agent = AgentAccount(login, password) data = agent.stories() Account.clear_cache() Story.clear_cache()
def test_update_location(login, password, id): agent = AgentAccount(login, password) location = Location(id) data = agent.update(location) Location.clear_cache()
def test_get_feed_long(login, password, count): agent = AgentAccount(login, password) data, pointer = agent.feed(count=count) assert (count >= len(data)) Account.clear_cache()
def test_follow_unfollow(login, password, username): agent = AgentAccount(login, password) account = Account(username) assert (agent.follow(account)) assert (agent.unfollow(account)) Account.clear_cache()
def test_update(login, password): agent = AgentAccount(login, password) agent.update() assert (not getattr(agent, "id") is None) Account.clear_cache()
def test_update_account(login, password, username): agent = AgentAccount(login, password) account = Account(username) data = agent.update(account) assert (not data is None) Account.clear_cache()
def test_update_photo_set(login, password, shortcode): agent = AgentAccount(login, password) photo_set = Media(shortcode) data = agent.update(photo_set) assert (not photo_set.is_video) Media.clear_cache()
def test_like_unlike_photo_set(login, password, shortcode): agent = AgentAccount(login, password) photo_set = Media(shortcode) assert (agent.like(photo_set)) assert (agent.unlike(photo_set)) Account.clear_cache() Media.clear_cache()
def test_update_video(login, password, shortcode): agent = AgentAccount(login, password) video = Media(shortcode) data = agent.update(video) assert (video.is_video) Media.clear_cache()
def test_like_unlike_video(login, password, shortcode): agent = AgentAccount(login, password) video = Media(shortcode) assert (agent.like(video)) assert (agent.unlike(video)) Account.clear_cache() Media.clear_cache()
def test_comment(login, password, shortcode): agent = AgentAccount(login, password) media = Media(shortcode) comment = agent.add_comment(media, "test") agent.delete_comment(comment) Account.clear_cache() Media.clear_cache() Comment.clear_cache()
def test_get_followers_long(login, password, count, username): agent = AgentAccount(login, password) account = Account(username) data, pointer = agent.get_followers(account, count=count) assert (min(account.followers_count, count) == len(data)) assert ((pointer is None) == (account.followers_count <= count)) Account.clear_cache()
def test_get_likes_long(login, password, count, shortcode): agent = AgentAccount(login, password) media = Media(shortcode) data, pointer = agent.get_likes(media, count=count) assert (min(media.likes_count, count) == len(data)) assert ((pointer is None) == (media.likes_count <= count)) Media.clear_cache()
def test_get_feed_pointer(login, password, count): agent = AgentAccount(login, password) pointer = None data = [] for i in range(count): tmp, pointer = agent.feed(pointer=pointer) data.extend(tmp) Account.clear_cache() Media.clear_cache()
def test_get_media_tag_long(login, password, count, name): agent = AgentAccount(login, password) tag = Tag(name) data, pointer = agent.get_media(tag, count=count) assert (min(tag.media_count, count) == len(data)) assert ((pointer is None) == (tag.media_count <= count)) Tag.clear_cache() Media.clear_cache()
def test_get_media_account(login, password, count, username): agent = AgentAccount(login, password) account = Account(username) data, pointer = agent.get_media(account, count=count) assert (min(account.media_count, count) == len(data)) assert ((pointer is None) == (account.media_count <= count)) Account.clear_cache() Media.clear_cache()
def test_get_media_location_long(login, password, count, id): agent = AgentAccount(login, password) location = Location(id) data, pointer = agent.get_media(location, count=count) assert (min(location.media_count, count) == len(data)) assert ((pointer is None) == (location.media_count <= count)) Location.clear_cache() Media.clear_cache()
def test_get_followers_pointer(login, password, count, username): agent = AgentAccount(login, password) account = Account(username) pointer = None data = [] for i in range(count): tmp, pointer = agent.get_followers(account, pointer=pointer) data.extend(tmp) assert ((pointer is None) == (account.followers_count <= count)) Account.clear_cache()
def test_get_likes_pointer(login, password, count, shortcode): agent = AgentAccount(login, password) media = Media(username) pointer = None data = [] for i in range(count): tmp, pointer = agent.get_likes(media, pointer=pointer) data.extend(tmp) assert ((pointer is None) == (media.likes_count <= count)) Account.clear_cache() Media.clear_cache()
def test_get_media_tag_pointer(login, password, count, name): agent = AgentAccount(login, password) tag = Tag(name) pointer = None data = [] for i in range(count): tmp, pointer = agent.get_media(tag, pointer=pointer) data.extend(tmp) assert ((pointer is None) == (tag.media_count <= count)) Account.clear_cache() Media.clear_cache() Tag.clear_cache()
def test_get_media_location_pointer(login, password, count, id): agent = AgentAccount(login, password) location = Location(id) pointer = None data = [] for i in range(count): tmp, pointer = agent.get_media(location, pointer=pointer) data.extend(tmp) assert ((pointer is None) == (location.media_count <= count)) Account.clear_cache() Media.clear_cache() Location.clear_cache()
def test_auth(login, password): agent = AgentAccount(login, password) Account.clear_cache()
def agent_account(settings): return AgentAccount(creds["login"], creds["password"], settings=settings)
from flask import Flask, send_file, send_from_directory from instaparser.agents import AgentAccount import json import os app = Flask(__name__) TOTAL = None username = os.environ.get('INSTAGRAM_USERNAME') password = os.environ.get('INSTAGRAM_PASSWORD') account = AgentAccount(username, password) file_path = os.environ.get("FILE_PATH") file_name = os.environ.get("FILE_NAME") def getFollowers(): global TOTAL account.update(account) amt_of_followers = account.followers_count foll_dict = dict() foll_dict['profile'] = username foll_dict['number'] = amt_of_followers if TOTAL is None: TOTAL = amt_of_followers else: if amt_of_followers > TOTAL: diff = amt_of_followers - TOTAL get_new_followers = account.get_followers(account=account, count=diff) new_followers = [str(item) for item in get_new_followers[0]]
from instaparser.agents import AgentAccount from instaparser.entities import Media agent = AgentAccount("vasiliyvasilenko8", "?naScar88") def check_likes(username, media): media = Media(media) pointer = 0 while not pointer is None: likes, pointer = agent.get_likes(media, pointer=pointer) for like in likes: if str(like) == username: return True return False