1

I am a newbie to Python, PIP and InstaPy.
I am trying to create a program that will like all the posts belonging to a specific user.
This is what I have written so far:

""" Quickstart script for InstaPy usage """
# imports
from instapy import InstaPy
from instapy import smart_run

# login credentials
insta_username = 'my_insta_username'  # <- enter username here
insta_password = 'my_insta_password'  # <- enter password here

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False)

with smart_run(session):
    """ Activity flow """
    # general settings
    session.set_relationship_bounds(enabled=True,
                                    delimit_by_numbers=True,
                                    max_followers=600,
                                    min_followers=100,
                                    min_following=77)

    session.set_dont_include(["friend1", "friend2", "friend3"])

    session.set_do_like(True, percentage=100)
    session.interact_by_users(['some_username'], media='None')

But the problem is that it ignores almost all the post made by some_username and only performs the sessions.set_do_like function on some of the posts.
Here is my console output:

INFO [2020-06-25 18:15:48] [my_insta_username]  -- Connection Checklist [1/3] (Internet Connection Status)
INFO [2020-06-25 18:15:51] [my_insta_username]  - Internet Connection Status: ok
INFO [2020-06-25 18:15:51] [my_insta_username]  - Current IP is "120.57.14.16" and it's from "India/IN"
INFO [2020-06-25 18:15:51] [my_insta_username]  -- Connection Checklist [2/3] (Instagram Server Status)
INFO [2020-06-25 18:16:10] [my_insta_username]  - Instagram WebSite Status: Currently Up
INFO [2020-06-25 18:16:10] [my_insta_username]  - Instagram Response Time: 98.113 ms
INFO [2020-06-25 18:16:10] [my_insta_username]  - Instagram Reponse Code: 200
INFO [2020-06-25 18:16:10] [my_insta_username]  - Instagram Server Status: ok
INFO [2020-06-25 18:16:10] [my_insta_username]  -- Connection Checklist [3/3] (Hide Selenium Extension)
INFO [2020-06-25 18:16:10] [my_insta_username]  - window.navigator.webdriver response: False
INFO [2020-06-25 18:16:10] [my_insta_username]  - Hide Selenium Extension: ok
................................................................................
INFO [2020-06-25 18:16:30] [my_insta_username]  Logged in successfully!
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
INFO [2020-06-25 18:16:30] [my_insta_username]  Saving account progress...
________________________________________________________________________________________
INFO [2020-06-25 18:16:51] [my_insta_username]  Starting to interact by users..
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
INFO [2020-06-25 18:16:51] [my_insta_username]  Username [1/1]
INFO [2020-06-25 18:16:51] [my_insta_username]  --> b'some_username'
INFO [2020-06-25 18:16:56] [my_insta_username]  User: 'some_username'  |> followers: 139  |> following: 114  |> relationship ratio: 1.21
INFO [2020-06-25 18:17:21] [my_insta_username]  username actions: following=False commenting=False liking=True story=False
INFO [2020-06-25 18:17:21] [my_insta_username]  Getting some_username image list...
ERROR [2020-06-25 18:17:49] [my_insta_username]  link_elems error local variable 'post_href' referenced before assignment
INFO [2020-06-25 18:18:10] [my_insta_username]  There are possibly less posts than 10 in some_username's profile page!
INFO [2020-06-25 18:18:10] [my_insta_username]  --> Not following
INFO [2020-06-25 18:18:11] [my_insta_username]  -------------
INFO [2020-06-25 18:18:11] [my_insta_username]  --> Given amount not fullfilled, image pool reached its end


INFO [2020-06-25 18:18:12] [my_insta_username]  Sessional Live Report:
        |> No any statistics to show


[Session lasted 2.59 minutes]
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2020-06-25 18:18:12] [my_insta_username]  Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

How do I fix this?

My system:
OS: Windows 10
Python: 3.8.3
PIP: 20.1.1
InstaPy: 0.6.8

Thanks in advance for your time and help!

hoefling
  • 59,418
  • 12
  • 147
  • 194
Samyak Jain
  • 29
  • 2
  • 6

2 Answers2

0

I got the same error, I've noticed that randomize=True multiplies the amount by ten, so just set it to false and you'll be set :) (are you samyak-mpstme?)

yozaam
  • 79
  • 6
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep, strftime
from random import randint
import pandas as pd

chromedriver_path ='C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe'# Change this to your own chromedriver path!
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
sleep(2)
webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
sleep(3)

username = webdriver.find_element_by_name('raj_raaz.18') # your username
username.send_keys('your_username')
password = webdriver.find_element_by_name('*******')  # your insta password
password.send_keys('your_password')

button_login = webdriver.find_element_by_css_selector('#react-root > section > 
main > div > article > div > div:nth-child(1) > div > form > div:nth-child(3) > button')
button_login.click()
sleep(3)

notnow = webdriver.find_element_by_css_selector('body > div:nth-child(13) > div > div > div > div.mt3GC > button.aOOlW.HoLwm')
notnow.click() #comment these last 2 lines out, if you don't get a pop up asking about notifications
Raj Maddheshiya
  • 485
  • 4
  • 5