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 am new with InstaPy and I would have few questions:
InstaPy(username=insta_username, password=insta_password)\
.login()\
.set_do_comment(True, percentage=100)\
.set_comments(['Amazing!','Nice!'])\
.like_by_tags(['natgeo', 'world'], amount=100)\
.end()
This is the error that I get in my terminal for every image:
...
--> Image Liked!
--> Warning: Comment Action Likely Failed: Comment Element not found
--> Commented: b'Amazing!'
--> Not following
...
Do you know how could I fix this?
How to follow accounts with like_by_tags?
Is it possible to unfollow an account after a certain amount of time if they don't follow back?
Lastly, to see if interact_user_followers works, I run this quickstart.py:
InstaPy(username=insta_username, password=insta_password)\
.login()\
.set_user_interact(amount=5, random=True, percentage=100, media='Photo')\
.set_do_follow(enabled=True, percentage=100)\
.set_do_like(enabled=True, percentage=100)\
.set_comments(["Cool", "Super!"])\
.set_do_comment(enabled=False, percentage=100)\
.interact_user_followers(['natgeo'], amount=10, random=True)\
.end()
Unfortunately, this is the error that I always get in my terminal:
following_link error
list index out of range
Traceback (most recent call last):
File "quickstart.py", line 23, in <module>
.interact_user_followers(['natgeo'], amount=10, random=True)\
File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 855, in interact_user_followers
userToInteract += get_given_user_followers(self.browser, user, amount, self.dont_include, self.username, self.follow_restrict, random)
File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/unfollow_util.py", line 286, in get_given_user_followers
dialog = browser.find_element_by_xpath('/html/body/div[4]/div/div[2]/div/div[2]/div/div[2]')
File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 293, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 752, in find_element
'value': value})['value']
File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[4]/div/div[2]/div/div[2]/div/div[2]"}
(Session info: chrome=60.0.3112.90)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.12.4-1-ARCH x86_64)
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x7fcb2ef7de10>>
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 163, in __del__
File "/usr/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 139, in stop
File "/usr/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 110, in send_remote_shutdown_command
ImportError: sys.meta_path is None, Python is likely shutting down
Do you know how could I fix this?
I am very sorry for this very long message.
Thank you so much in advance,
Best,
Tom
I am very sorry for this very long message. Maybe it is too long with too many questions... If it's the case please just consider the parts that you prefer.
Best,
Thomas
Hi,
I just did a git pull and apparently the latest solved my problems 1 and 4 and I found myself the solution for question 2. My only remaining question is question 3:
-> Is it possible to unfollow an account after a certain amount of time if they don't follow back?
Thanks in advance,
Best,
Thomas
@thomascello sorry unfortunately unfollowing is not that smart yet
Just on problem actually remains 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
@thomascello Did you do a git pull lately?
I did. Unfortunately this doesn't solve the problem.
Thanks for your help!
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