示例#1
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
示例#2
0
# print('External Url: ', account.external_url)
# print('Number of published posts: ', account.media_count)
# print('Number of followers: ', account.followed_by_count)
# print('Number of follows: ', account.follows_count)
# print('Is private: ', account.is_private)
# print('Is verified: ', account.is_verified)

# # or simply for printing use 
# print(account)

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

instagram = Instagram()
instagram.with_credentials('username', 'password', '/cachepath')
instagram.login(force=False,two_step_verificator=True)

sleep(2) # Delay to mimic user

# username = '******'
# followers = []
# account = instagram.get_account(username)
# sleep(1)
# followers = instagram.get_followers(account.identifier, 150, 100, delayed=True) # Get 150 followers of 'kevin', 100 a time with random delay between requests

# for follower in followers['accounts']:
#     print(follower)