1

我是 Python、PIP 和 InstaPy 的新手。
我正在尝试创建一个程序,该程序将喜欢属于特定用户的所有帖子。
这是我到目前为止所写的:

""" 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')

但问题是它忽略了几乎所有的帖子some_username,只sessions.set_do_like对部分帖子执行功能。
这是我的console输出:

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

我该如何解决?

我的系统:
操作系统:Windows 10
Python:3.8.3
PIP:20.1.1
InstaPy:0.6.8

提前感谢您的时间和帮助!

4

2 回答 2

0

我遇到了同样的错误,我注意到 randomize=True 将数量乘以十,所以只需将其设置为 false,您就会被设置 :)(您是 samyak-mpstme 吗?)

于 2020-06-27T15:33:30.887 回答
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
于 2022-02-17T10:21:56.737 回答