def connect():
    global account_flag
    username, password = get_account()
    print(account_flag)
    instagram = Instagram()
    instagram.with_credentials(username, password, path_to_cache_folder)
    instagram = Instagram()
    print("connected")
    return instagram
Example #2
0
from context import Instagram # pylint: disable=no-name-in-module
import time

instagram = Instagram()
instagram.with_credentials('JJPtest123', 'jjptest', '/pathtocache')
instagram.login()

# If account is public you can query Instagram without auth

instagram = Instagram()

#f = open('lilmiquela.txt', 'w', encoding="utf-8")

#account_name = input("The account name: ")
#account_post_number = input("The number of post: ")
#medias = instagram.get_medias(account_name, account_post_number)

medias = instagram.get_medias("lilmiquela", 610)

#将时间戳转换为普通时间
def time_tran(created_at):
    time_local = time.localtime(created_at)
    created_time = time.strftime("%Y-%m-%d %H:%M:%S",time_local)
    return created_time

#media = medias[0]
#account = media.owner
#print(account.get_username())

cont = 0
Example #3
0
from context import Instagram # pylint: disable=no-name-in-module
from time import sleep

instagram = Instagram()
instagram.with_credentials('username', 'password', 'pathtocache')
instagram.login()

sleep(2) # Delay to mimic user

username = '******'
following = []
account = instagram.get_account(username)
sleep(1)
following = instagram.get_following(account.identifier, 150, 100, delayed=True) 
for following_user in following['accounts']:
    print(following_user)
#TODO does not work currently instagram changed api
from time import sleep
from context import Instagram  # pylint: disable=no-name-in-module

instagram = Instagram.with_credentials('username', 'password',
                                       'path/to/cache/folder')
instagram.login()

sleep(2)  # Delay to mimic user

username = '******'
followers = []
account = instagram.get_account(username)
sleep(1)
followers = instagram.get_followers(
    account.identifier, 1000, 100, True
)  # Get 1000 followers of 'kevin', 100 a time with random delay between requests
print(followers)
from context import Instagram  # pylint: disable=no-name-in-module
from time import sleep

instagram = Instagram()
instagram.with_credentials('james_kumar_129', '4[PQ)yRE7.M;cq3',
                           '/home/robin/projects/instagram-scraper/cache')
instagram.login()

sleep(2)  # Delay to mimic user

username = '******'
following = []
account = instagram.get_account(username)
sleep(1)
following = instagram.get_following(account.identifier, 150, 100, delayed=True)
for following_user in following['accounts']:
    print(following_user)
from context import Instagram # pylint: disable=no-name-in-module

instagram = Instagram()
instagram.with_credentials('mollyc773', 'qq767138291', 'path/to/cache/folder')
instagram.login()

medias = instagram.get_current_top_medias_by_tag_name('youneverknow')
media = medias[0]

print(media)
print(media.owner)
from context import Instagram  # pylint: disable=no-name-in-module

instagram = Instagram()
instagram.with_credentials('JJPtest123', 'jjptest', 'path/to/cache/folder')
instagram.login()

media = instagram.get_media_by_id('2143248849565463035')

#not optimal to many calls
tagged_users = instagram.get_media_tagged_users_by_code(media.shortCode)

print(tagged_users)
Example #8
0
from context import Instagram  # pylint: disable=no-name-in-module

instagram = Instagram.with_credentials('', '', 'pathtocache')
instagram.login()

instagram.follow('user_id')
#instagram.unfollow('')
Example #9
0
from context import Instagram  # pylint: disable=no-name-in-module

instagram = Instagram()
instagram.with_credentials('', '', '/pathtofolder')
instagram.login()

# Get media comments by shortcode
likes = instagram.get_media_likes_by_code('BG3Iz-No1IZ', 100)

print("Result count: " + str(len(likes['accounts'])))

for like in likes['accounts']:
    print(like)

# ...
from context import Instagram  # pylint: disable=no-name-in-module

instagram = Instagram()
instagram.with_credentials('', '', '/pathtocache')
instagram.login()

# echo "Number of comments: {$medias[0]->get_comments_count()}\n";
# echo "Fetched: " . count($comments) . "\n";
# or by id
comments = instagram.get_media_comments_by_id('1130748710921700586', 10000)

for comment in comments['comments']:
    print(comment.text)
    print(comment.owner)

# You can start loading comments from specific comment by providing comment id
# comments = instagram.getMediaCommentsByCode('BG3Iz-No1IZ', 200, comment.identifier)