Instapy: See all suggestion

Created on 11 Oct 2018  路  18Comments  路  Source: timgrossmann/InstaPy

I have 2 users that all is going great, but one of them always getting 12 people to follow them.
but it's going on only in one account...
image

The 'See all suggesting' is only in this account when i use the comment:

session.follow_user_followers(['or_shahar21'], amount=1000, randomize=True, sleep_delay=200)

The 'See all suggesting' is making a big problem and i want to know why it's happenning only in this account?

Thanks
@uluQulu
@timgrossmann

wontfix

All 18 comments

I think it is time to look into this case.
Who can solve it?

I think it is time to look into this case.
Who can solve it?

less important thing is why it's happenning only in 1 account maybe this account configurations or somthing? if we can settle this issue like that it would be great, because other accounts dont have this 'feature'...
i will try to find somthing...

@AvocadoStyle
That case has been around for a while and I think now it might have been stabilized a bit so that can be handled.
By your feedback, it means it still is a pilot feature and is being only partially applied to service.

Possible solution will be to handle both scenarios:

  • older [current normal code] layout
  • newer [needs new code] layout
  • and handler to detect the layout status.

@AvocadoStyle
That case has been around for a while and I think now it might have been stabilized a bit so that can be handled.
By your feedback, it means it still is a pilot feature and is being only partially applied to service.
Possible solution will be to handle both scenarios:
older [current normal code]
newer [needs new code]
and handler to detect the layout status.

ok... i see this happenning only with the 'google chrome' driver... when i log by the google chrome brower this is not happenning... maybe instagram is recognaizzing the google chrome driver or somthing? or I talking bullshit lol...
@uluQulu

when it's manage to press the 'See all suggesting'
it's doing this exception:

INFO [2018-10-11 15:03:06] [moshe12427] Session ended!
Traceback (most recent call last):
File "C:\Users\ccduser\Desktop\best_instapy\InstaPy-master\moshe12427.py", line 34, in
session.follow_user_followers(['adirbriga7'], amount=1000, randomize=True, sleep_delay=700)
File "C:\Users\ccduser\Desktop\best_instapy\InstaPy-master\instapy\instapy.py", line 2504, in follow_user_followers
self.logfolder)
File "C:\Users\ccduser\Desktop\best_instapy\InstaPy-master\instapy\unfollow_util.py", line 906, in get_given_user_followers
channel, jumps, logger, logfolder)
File "C:\Users\ccduser\Desktop\best_instapy\InstaPy-master\instapy\unfollow_util.py", line 713, in get_users_through_dialog
person_list = dialog_username_extractor(buttons)
File "C:\Users\ccduser\Desktop\best_instapy\InstaPy-master\instapy\unfollow_util.py", line 736, in dialog_username_extractor
if person and hasattr(person, 'text') and person.text:
File "C:\Users\ccduser\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 76, in text
return self._execute(Command.GET_ELEMENT_TEXT)['value']
File "C:\Users\ccduser\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\ccduser\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Users\ccduser\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.15063 x86_64)

Process finished with exit code 0

driver...

This bot security is under the standard.
Do you think this issue is related to driver ? I don't think so.

can i share something im getting recently but i don't know if its related !

[1011/190959.957:INFO:CONSOLE(0)] "The Content Security Policy directive 'upgrade-insecure-requests' is ignored when delivered in a report-only policy.", source: https://www.instagram.com/mhdtob/ (0)

There is another issue you should be aware about. Once clicking on "See all suggestions", there is a limited amount of users when scrolling down. I'd say around max 100. So even if we fix this issue we'll run into another one where we're limited to max 100 users. You can check it out yourself manually and validate this.

My solution (which is very "dirty" and quick) is as follows:

In follow_through_dialog method under the method "scroll bottom" add the following:

    scroll_bottom(browser, dialog, amount_left)
    try:
        suggestion_button = browser.find_element_by_xpath("//*[contains(text(), 'See All Suggestions')]")
    except:
        suggestion_button = None
    if suggestion_button:
        suggestion_button.click()
        sleep(2)
        dialog = browser

In scroll_bottom method, inside the loop add this:

        if element is not browser:
            browser.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", element)
        else:
            browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")

POSSIBLE SOLUTION!!! I found out that when scrolling slowly instead of aggressively (not only by amount of times but also by scrolling height per each scroll), the "See all suggestions" doesn't appear! Would appreciate additional testing on this. If this is true, all we need to do is update the scroll_bottom method to scroll slower and more delicate @uluQulu

POSSIBLE SOLUTION!!! I found out that when scrolling slowly instead of aggressively (not only by amount of times but also by scrolling height per each scroll), the "See all suggestions" doesn't appear! Would appreciate additional testing on this. If this is true, all we need to do is update the scroll_bottom method to scroll slower and more delicate @uluQulu

yes you right this is the solution i think... we just need to make it faster, the 'All suggestions' us happenning to me only when i use the driver, but i did scroll by myself when the driver was running and now it's working great... i will try to find a solution to scroll like i did manually... if you have a solution please send it to here @assafelovic

@uluQulu i found a solution, just tell me how can i scroll up(when searching) at unfollow util or in utill, thanks @assafelovic

@AvocadoStyle
To scroll up you can use these javascript functions,

  • scrollBy(x, y) - much easier
dialog = $x("//div[text()='Following']/../../following-sibling::div")[0];
dialog.scrollBy(0, -648);

It will scroll up with the y value of -638, in other words, it will scroll backwards at that amount.
Why 638? - _I tested and it scrolls at 638 per each scroll down_.
You can put any value you find reasonable.
And can use it at InstaPy as below,

dialog = browser.find_element_by_xpath("//div[text()='Following']/../../following-sibling::div")
browser.execute_script("{}.scrollBy(0, -638);".format(dialog))
  • scrollTo(x, y) - more customizable
dialog = $x("//div[text()='Following']/../../following-sibling::div")[0];
dialog.scrollTo(0, dialog.scrollHeight/3);

You don't need the x coordinates cos it is not in use, cos only y moves on scrolls.


Cheers 馃攳

@AvocadoStyle
To scroll up you can use these javascript functions,

  • scrollBy(x, y) - much easier
dialog = $x("//div[text()='Following']/../../following-sibling::div")[0];
dialog.scrollBy(0, -648);

It will scroll up with the y value of -638, in other words, it will scroll backwards at that amount.
Why 638? - _I tested and it scrolls at 638 per each scroll down_.
You can put any value you find reasonable.
And can use it at InstaPy as below,

dialog = browser.find_element_by_xpath("//div[text()='Following']/../../following-sibling::div")
browser.execute_script("{}.scrollBy(0, -638);".format(dialog))
  • scrollTo(x, y) - more customizable
dialog = $x("//div[text()='Following']/../../following-sibling::div")[0];
dialog.scrollTo(0, dialog.scrollHeight/3);

You don't need the x coordinates cos it is not in use, cos only y moves on scrolls.

Cheers 馃攳

@uluQulu
@sionking

In the util.py we have this function

def scroll_bottom(browser, element, range_int):
# put a limit to the scrolling
if range_int > 50:
range_int = 50

for i in range(int(range_int / 2)):
    browser.execute_script(
        "arguments[0].scrollTop = arguments[0].scrollHeight", element)
    # update server calls
    update_activity()
    sleep(1)

return

this function is the function that toggle the page down, I've tried to toggle the scroll bar with the functions you gave me, and i didn't success to do it in any way... it's just not doing anything... not only your functions that you wrote here, any function that i found...
so we need just to toggle the scrollbar slowly down thats it and i will do the job, and the 'All suggesting' button will not appear.

    browser.execute_script(
        "arguments[0].scrollTop = arguments[0].scrollHeight", element)

@assafelovic tried to do your solution unsuccessfully its sending you to another page, we need to toggle the scroll slowly, i've tried to do it unsuccessfully

+1 having this problem. Any progress?

I was having this problem in a different project (found my way here trying to fix it) and I found that if you scroll back up and then scroll down more slowly, the followers will load. Right now my code is something hideous like:

if "See All Suggestions" in followers_box.text:
                #Scroll to top
                browser.execute_script("arguments[0].scrollTo(0,0)", followers_box)
                sleep(randint(2,3))
                #Scroll down more slowly
                browser.execute_script("arguments[0].scrollTo(0,100)", followers_box)

And just scroll down by degrees a few times (100, 200, 500, then all the way down), sleeping in between. I know there's a nicer way to do it, but this works for now.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tibor picture tibor  路  3Comments

ingorichter picture ingorichter  路  3Comments

drcyber975 picture drcyber975  路  3Comments

converge picture converge  路  3Comments

CodeMaster1 picture CodeMaster1  路  3Comments