Instapy: One small issue with like_by_tags

Created on 31 Aug 2017  路  30Comments  路  Source: timgrossmann/InstaPy

Hi,

First of all, I would like to deeply thank you for all your work and for running such a cool open-source project!

I just have one problem with this quickstart.py:

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .set_lower_follower_count(limit = 20)\
  .set_upper_follower_count(limit = 2000)\
  .set_do_follow(enabled=True, percentage=100)\
  .set_do_comment(True, percentage=70)\
  .set_comments(['Super!','Nice!','Cool'])\
  .like_by_tags(['followme'], amount=100)\
  .end()

I got this error at some point:

[7/33]
Image from: b'bruhmusicals'
Number of Followers: 399157
Link: b'https://www.instagram.com/p/BYdcFanFczK/?tagged=followme'
Description: b'Comment "prank" letter by letter\xf0\x9f\x98\x82 // Follow @bruhmusicals if you\'re viewing\xf0\x9f\x94\xa5'
--> Image Liked!
--> Commented: b'Super!'
Traceback (most recent call last):
  File "quickstart.py", line 15, in <module>
    .set_comments(['Super!','Nice!','Cool'])\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 531, in like_by_tags
    followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/unfollow_util.py", line 134, in follow_user
    follow_button.send_keys("\n")
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 350, in send_keys
    'value': keys_to_typing(value)})
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Can you help me on this?

Thanks so much
Best

bug help wanted

Most helpful comment

Even after the latest pull (#620) , i'm still getting this error.

All 30 comments

I just got this too, but half way through my run... I'm not sure whats happening but I just started another run and I'm monitoring it. it's strange for it to be working fine and then stopping randomly.

Yes! I got exactly the same issue! Any idea where this is coming from?

best,
Thomas

I just found a pattern: when I am running two quickstart files at the same time to have more interactions with followers in a certain amount of time, the error occurs way more often.

quickstart1.py

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .set_lower_follower_count(limit=20)\
  .set_user_interact(amount=3, random=True, percentage=100, media='Photo')\
  .set_do_follow(enabled=True, percentage=100)\
  .set_do_like(enabled=True, percentage=100)\
  .set_comments(["Cool", "Super!","Nice!"])\
  .set_do_comment(enabled=True, percentage=50)\
  .interact_user_followers(['natgeo'], amount=100, random=True)\
  .end() 

quickstart2.py

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .set_lower_follower_count(limit=20)\
  .set_user_interact(amount=3, random=True, percentage=100, media='Photo')\
  .set_do_follow(enabled=True, percentage=100)\
  .set_do_like(enabled=True, percentage=100)\
  .set_comments(["Cool", "Super!","Nice!"])\
  .set_do_comment(enabled=True, percentage=50)\
  .interact_user_followers(['photographicalgoals'], amount=100, random=True)\
  .end() 

Error message

Username [3/37]
--> b'duhitssean19'
Getting  duhitssean19 image list...
Interaction begin...

Traceback (most recent call last):
  File "User.py", line 15, in <module>
    .interact_user_followers(['photographers_uniteds_'], amount=50, random=True)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 864, in interact_user_followers
    self.like_by_users(userToInteract, self.user_interact_amount, self.user_interact_random, self.user_interact_media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 583, in like_by_users
    links = get_links_for_username(self.browser, username, amount, random, media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/like_util.py", line 304, in get_links_for_username
    links = [link_elem.get_attribute('href') for link_elem in link_elems
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/like_util.py", line 305, in <listcomp>
    if link_elem.text in media]
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 74, in text
    return self._execute(Command.GET_ELEMENT_TEXT)['value']
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, 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=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Thanks for your help!
Best,
Thomas

Me too

Same here!
It's a fatal one, my sessions never reach the end now due to this error.
Sometimes it occurs after a few minutes, sometimes after a few hours. Seemingly entirely random.
Error message:

    followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
  File "/root/instapy/instapy/unfollow_util.py", line 134, in follow_user
    follow_button.send_keys("\n")
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 320, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
  (Session info: chrome=60.0.3112.113)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-93-generic x86_64)

Hi, I have change the xpath of _unfollow_util.py_ on line 132
From:
follow_button = browser.find_element_by_xpath("//button[text()='Follow']")
To:
follow_button = browser.find_element_by_xpath("//*[contains(text(), 'Follow')]")
It seems work.
Why the bot don't get only button with the text 'xxx' but all element contains xxx? @timgrossmann

Thanks! I'm testing your fix right now!

I will keep you informed if that works !

Best,
Thomas

I just tried twice and I still have the same error message:

Username [1/30]
--> b'anastasia_ro8'
Getting  anastasia_ro8 image list...
Interaction begin...

Traceback (most recent call last):
  File "User.py", line 15, in <module>
    .interact_user_followers(['photographers_uniteds_'], amount=50, random=True)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 864, in interact_user_followers
    self.like_by_users(userToInteract, self.user_interact_amount, self.user_interact_random, self.user_interact_media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 583, in like_by_users
    links = get_links_for_username(self.browser, username, amount, random, media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/like_util.py", line 253, in get_links_for_username
    load_button.click()
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 78, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a href="/anastasia_ro8/?max_id=1544755926739836390" class="_1cr2e _epyes">...</a> is not clickable at point (469, 67). Other element would receive the click: <div class="_5rnaq">...</div>
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Sorry...

620 Please do a git pull and try again

Sorry, I did a git pull and try twice and still an error message...

Traceback (most recent call last):
  File "User.py", line 16, in <module>
    .interact_user_followers(['photographers_uniteds_'], amount=100, random=True)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 864, in interact_user_followers
    self.like_by_users(userToInteract, self.user_interact_amount, self.user_interact_random, self.user_interact_media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 593, in like_by_users
    followed += follow_user(self.browser, self.follow_restrict, self.username, username)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/unfollow_util.py", line 136, in follow_user
    follow_button.send_keys("\n")
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 350, in send_keys
    'value': keys_to_typing(value)})
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, 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=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Thanks for your help!

@thomascello you have different error each time, It's not the same.

I know... Maybe because I did git pull between each of these runs (that gave rise to these error messages)

Have you try my fix after pull?

Yes, indeed I try with you fix but I still have an error message.

Username [1/30]
--> b'anastasia_ro8'
Getting  anastasia_ro8 image list...
Interaction begin...

Traceback (most recent call last):
  File "User.py", line 15, in <module>
    .interact_user_followers(['photographers_uniteds_'], amount=50, random=True)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 864, in interact_user_followers
    self.like_by_users(userToInteract, self.user_interact_amount, self.user_interact_random, self.user_interact_media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 583, in like_by_users
    links = get_links_for_username(self.browser, username, amount, random, media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/like_util.py", line 253, in get_links_for_username
    load_button.click()
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 78, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a href="/anastasia_ro8/?max_id=1544755926739836390" class="_1cr2e _epyes">...</a> is not clickable at point (469, 67). Other element would receive the click: <div class="_5rnaq">...</div>
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Thanks so much for your help!

@thomascello This is really weird, since, as far as I've seen, all the .click() have been replaced...

I totally agree @timgrossmann, that's weird. However, that happens almost always when I run two scripts at the same time...

Traceback (most recent call last):
  File "User2.py", line 14, in <module>
    .interact_user_followers(['everchanginghorizon'], amount=100, random=True)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 864, in interact_user_followers
    self.like_by_users(userToInteract, self.user_interact_amount, self.user_interact_random, self.user_interact_media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 583, in like_by_users
    links = get_links_for_username(self.browser, username, amount, random, media)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/like_util.py", line 253, in get_links_for_username
    load_button.click()
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 78, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a href="/top_gun_tactical/?max_id=1501126897865932272" class="_1cr2e _epyes">...</a> is not clickable at point (469, 17). Other element would receive the click: <span class="_96n9j">...</span>
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.8-2-ARCH x86_64)

Thanks so much for your help,
Thomas

@thomascello Oh, you definitely shouldn't run two scripts at the same time 馃槄
Should only work without problems by using docker...

Sorry I didn't know that. Therefore, how can I accelerate the process without running two scripts at the same time. Because for now, it takes around 2 minutes to interact with one user whereas I have a quite good computer and it is a bit slow for what I would like to do.

Thanks so much for your help,
Best,
Thomas

Even after the latest pull (#620) , i'm still getting this error.

@thomascello I believe the 2 minutes between interactions is intentional. You don't want to do too many actions too fast on Instagram because your traffic may be seen as a bot and you could get banned. Slow and steady my friend.

Haha thanks so much @Implicit989 for your help and your advice ;)
Just to know, is it still possible to accelerate to process (with of course the big risk of being banned) or run two scripts at the same time?

Thanks so much again and please have a good day,
Best,
Thomas

Any solutions yet?

Also waiting for any solutions finally. This issue has broke my automation script and I'm quite frustrated it still hasn't been resolved. :/

This might be related to clarifai. I've had luck by doing the following.

I've added .set_use_clarifai(enabled=False)\ to my script.

I've also added sleep(8) before the follow button click in instapy.py. The combo of the two has allowed my script to go further in the run with rarely an error.

Hope this can help someone else!

@alexmourer I'm trying this. Will get back here if it works for me or not. I just hope it does work well.

@alexmourer Thanks for helping but I just tried adding session.set_use_clarifai(enabled=False) to my scripts and that didn't affect it at all... I will wait for @kushpvo to test if sleep(8) affects it as I rather not modify my instapy.py (if it does improve it, best thing would be a pull).

I did try both the things that @alexmourer mentioned; but the error still remained, it did affect at all.
Waiting for a solution badly :(

I'm pretty sure this started happening with a commit from around August 30. Maybe just downgrading would be a sufficient solution for now?

Any news?

There is no interaction for a long time, please reopen it if you still need some help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thisishotdog picture thisishotdog  路  3Comments

wyvers picture wyvers  路  3Comments

drcyber975 picture drcyber975  路  3Comments

ingorichter picture ingorichter  路  3Comments

46960 picture 46960  路  3Comments