Beispiel #1
0
    def instaLogin(self):
        #pip install git+ssh://[email protected]/ping/[email protected]
        print('Insta Client version: %s' % app_api.__version__)
        api = None
        username = self.InstaUsername
        password = self.InstaPassword
        settings_file = self.settings_file_insta
        try:
            if not os.path.isfile(settings_file):
                # settings file does not exist
                print('Unable to find file: %s' % settings_file)
                # login new
                api = app_api.Client(
                    username,
                    password,
                    on_login=lambda x: self.onlogin_callback(x, settings_file))
            else:
                with open(settings_file) as file_data:
                    cached_settings = json.load(file_data)
                print('Reusing settings: %s' % settings_file)

                # reuse auth settings
                api = app_api.Client(username,
                                     password,
                                     settings=cached_settings)
        except (app_api.ClientCookieExpiredError,
                app_api.ClientLoginRequiredError) as e:
            print('ClientCookieExpiredError/ClientLoginRequiredError: %s' % e)
            # Login expired
            # Do relogin but use default ua, keys and such
            api = app_api.Client(
                username,
                password,
                on_login=lambda x: self.onlogin_callback(x, settings_file))
        except app_api.ClientLoginError as e:
            print('ClientLoginError %s' % e)
            pass
        except app_api.ClientError as e:
            print('ClientError %s (Code: %d, Response: %s)' %
                  (e.msg, e.code, e.error_response))
            pass
        except Exception as e:
            print('Unexpected Exception: %s' % e)
            pass

        # Show when login expires
        if api:
            cookie_expiry = api.cookie_jar.expires_earliest
            print('Cookie Expiry: %s' % datetime.datetime.fromtimestamp(
                cookie_expiry).strftime('%Y-%m-%dT%H:%M:%SZ'))
        return api
Beispiel #2
0
 def __init__(self):
     self.topsearchUrl = "https://www.instagram.com/web/search/topsearch/?context=blended&query="
     self.locationExploreUrl = "https://www.instagram.com/explore/locations/"
     user_name = 'jerry_jiarui_xu'
     password = '******'
     self.app_api = instagram_private_api.Client(user_name, password)
     self.web_api = instagram_web_api.Client()
Beispiel #3
0
def check_users(login_information: Dict[str, str]) -> Dict[str, str]:
    """
    The instagram API is fickle. Users are blocked due to downloading too much data (sentry error) or suspicious logins
    (checkpoint challenge). This will only return users which can download data.
    :param login_information: dictionary. keys: usernames. values: passwords.
    :return: dictionary of working logins
    """
    working_logins = {}
    for username, password in login_information.items():
        try:
            api = instagram_private_api.Client(username, password)
            api.login()
            api.logout()
            working_logins[username] = password
        except instagram_private_api.errors:
            pass
    return working_logins
Beispiel #4
0
def login(username: str, password: str):
    """
    Logs into instagram-api using username and password
    :param username:
    :param password:
    :return: api or failed username
    """
    error = True
    while error:
        try:
            api = instagram_private_api.Client(username, password)
            api.login()
            return api
        except instagram_private_api.errors.ClientCheckpointRequiredError:
            print(f" Checkpoint challenge required, user {username} failed, returning..")
            return username
        except instagram_private_api.errors.ClientSentryBlockError:
            print(f"Sentry block error, user {username} failed, returning...")
            return username
        except instagram_private_api.errors.ClientError as clienterror:
            print(f'{clienterror.msg}')
            return username
Beispiel #5
0
user_name = 'user'
password = '******'

data = {}
with open('followers.json') as f:
    data = json.load(f)

followers = []

for person in data.get("relationships_followers"):
    followers.append(person.get("string_list_data")[0].get("value"))

followers_data = {}

api = ipa.Client(user_name, password)

while len(followers) != 0:
    try:
        username = followers[0]
        user_info = api.username_info(username)
        follower_count = user_info.get("user").get("follower_count")
        print(username + ":" + str(follower_count))
        followers_data.update({username: follower_count})
        followers.pop(0)
    except ipa.errors.ClientThrottledError as e:
        api.logout()
        api = ipa.Client(user_name, password)
        print(e)
        print("Still processing " + str(len(followers)) + " followers ...")
        time.sleep(10)
import string
import random
import json


class MyClient(instagram_web_api.Client):
    @staticmethod
    def _extract_rhx_gis(html):
        options = string.ascii_lowercase + string.digits
        text = ''.join([random.choice(options) for _ in range(8)])
        return hashlib.md5(text.encode()).hexdigest()


# Without any authentication
web_api = MyClient(auto_patch=True, drop_incompat_keys=False)
private_api = instagram_private_api.Client('jordanemedlock',
                                           'kGcBKXFbAnjdcp79gq!V')
jem_id = '5564617835'


def get_user_followings(user_id):
    uuid = private_api.generate_uuid()
    following_users = private_api.user_following(user_id, uuid)
    return following_users['users']


def get_username_info(username):
    print('getting username info: {}'.format(username))
    info = private_api.username_info(username)
    return info['user']
                        dest='username',
                        type=str,
                        required=True)
    parser.add_argument('-p',
                        '--password',
                        dest='password',
                        type=str,
                        required=True)
    parser.add_argument('-debug', '--debug', action='store_true')

    args = parser.parse_args()
    if args.debug:
        logger.setLevel(logging.DEBUG)

    print('Client version: %s' % app_api.__version__)
    api = app_api.Client(args.username, args.password)

    user_id = '2958144170'
    followers = []
    results = api.user_followers(user_id)
    followers.extend(results.get('users', []))

    next_max_id = results.get('next_max_id')
    while next_max_id:
        results = api.user_followers(user_id, max_id=next_max_id)
        followers.extend(results.get('users', []))
        if len(followers) >= 600:  # get only first 600 or so
            break
        next_max_id = results.get('next_max_id')

    followers.sort(key=lambda x: x['pk'])
    args = parser.parse_args()
    if args.debug:
        logger.setLevel(logging.DEBUG)

    print('Client version: %s' % app_api.__version__)

    try:

        settings_file = args.settings_file_path
        if not os.path.isfile(settings_file):
            # settings file does not exist
            print('Unable to find file: %s' % settings_file)

            # login new
            api = app_api.Client(
                args.username, args.password,
                on_login=lambda x: onlogin_callback(x, args.settings_file_path))
        else:
            with open(settings_file) as file_data:
                cached_settings = json.load(file_data, object_hook=from_json)
            print('Reusing settings: %s' % settings_file)

            # reuse auth settings
            api = app_api.Client(
                args.username, args.password,
                settings=cached_settings)

    except (app_api.ClientCookieExpiredError, app_api.ClientLoginRequiredError) as e:
        print('ClientCookieExpiredError/ClientLoginRequiredError: %s' % e)

        # Login expired
Beispiel #9
0
''' 
github.com/razyar
'''

import instagram_private_api as api 
import sys


try:
	instagram = api.Client('your_username', 'your_password')
	print 'Login sucessfully'
except Exception as LoginError:
	print 'Cannot login right now, check this error message and for solve go to https://github.com/razyar'
	sys.exit(0)


# i write some commands for you but you can use idle or read docks

'''
instagram.user_incoming_requests()
instagram.user_follows(user_id)*
instagram.user_followed_by(user_id)*
instagram.follow_user(user_id)
instagram.unfollow_user(user_id)
instagram.block_user(user_id)
instagram.unblock_user(user_id)
instagram.approve_user_request(user_id)
instagram.ignore_user_request(user_id)
instagram.user_relationship(user_id)
'''
#you can get more commands help from my github page.