follow_button.text should be the same as the seen on the GUI. According to the code "Following", "Follow" og "Follow back"
follow_button.text is always empty resulting in the code trying to find browser.find_element_by_xpath("//*[contains(text(), 'Requested')]") which is not present and thus an exception is thrown.
When browser.find_element_by_xpath("//*[contains(text(), 'Requested')]") is called and the the status acctually is requsted everything works fine.
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
Settings.log_location = os.path.join(BASE_DIR, 'myLogs')
Settings.database_location = os.path.join(BASE_DIR, 'myLogs', insta_username+'.db')
# set headless_browser=True if you want to run InstaPy on a server
# set these in instapy/settings.py if you're locating the
# library in the /usr/lib/pythonX.X/ directory:
# Settings.database_location = '/path/to/instapy.db'
# Settings.chromedriver_location = '/path/to/chromedriver'
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
multi_logs=True)
try:
session.login()
# settings
session.set_relationship_bounds(enabled=True,
potency_ratio=-1.0,
delimit_by_numbers=True,
max_followers=4590,
max_following=5555,
min_followers=40,
min_following=50)
session.set_do_comment(False, percentage=10)
session.set_do_like(True, percentage=51)
session.set_dont_include(dont_include)
session.unfollow_users(amount=100, InstapyFollowed=(True, "nonfollowers"), style="RANDOM", unfollow_after=4 * 24 * 60 * 60,
sleep_delay=601)
Cannot reproduce now....closing
And it is back....reopening
With this user:
The follow_button.text is empty. Resulting in trying to find "Requested" button that throws an exception.
Resulting in the user beeing removed from followedPool.csv without beeing unfollowed
INFO [2018-09-16 09:35:40] [meinerttt] Ongoing Unfollow [10/43]: now unfollowing 'b'louisrygaard''...
ERROR [2018-09-16 09:55:05] [meinerttt] --> Unfollow issue with 'b'louisrygaard''! ~unable to detect the following status
INFO [2018-09-16 09:55:17] [meinerttt] Pinging 'instagram.com' to check the connectivity...
Pinging instagram.com [34.194.59.113] with 32 bytes of data:
Reply from 34.194.59.113: bytes=32 time=167ms TTL=231
Ping statistics for 34.194.59.113:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 167ms, Maximum = 167ms, Average = 167ms
INFO [2018-09-16 09:55:17] [meinerttt] Checking if 'meinerttt' is logged in...
WARNING [2018-09-16 09:55:27] [meinerttt] Maybe 'b'louisrygaard'' has changed the username! ~verifying through the user ID
ERROR [2018-09-16 09:56:23] [meinerttt] --> Unfollow issue with 'b'louisrygaard''! ~unable to detect the following status
WARNING [2018-09-16 09:56:30] [meinerttt] --> Couldn't access the profile page of 'b'louisrygaard''! ~user has either closed the profile or blocked you
INFO [2018-09-16 09:56:31] [meinerttt] Removed '2018-09-10 08:43 ~ louisrygaard ~ 4734155943' from followedPool.csv file
Hello @meinert
It is another bug π
Thanks for raising!
Gonna share a solution soon π
The solution- https://github.com/timgrossmann/InstaPy/pull/2901/commits/54e607c84ff50a5d60a4ca7f88bf8f7517832404 is shared at #2901 PR https://github.com/timgrossmann/InstaPy/pull/2901#issuecomment-421847088.
_Now it should solve your problems_.
IF not works as expected, let me know ππΌπ¨πΌβπ»
@uluQulu
Same issue here:
INFO [2018-09-18 00:59:13] [awsmplace] Starting to unfollow users..
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
INFO [2018-09-18 00:59:13] [awsmplace] Unfollowing the users followed by InstaPy
INFO [2018-09-18 00:59:13] [awsmplace] Total 2323 users available to unfollow ~didn't pass `unfollow_after`: 0
INFO [2018-09-18 00:59:13] [awsmplace] Ongoing Unfollow [1/600]: now unfollowing 'b'okfiiige''...
INFO [2018-09-18 00:59:16] [awsmplace] --> Couldn't unfollow 'b'okfiiige''! ~maybe unfollowed before
INFO [2018-09-18 00:59:16] [awsmplace] Removed '2018-09-09 02:00 ~ okfiiige ~ 6045903017' from followedPool.csv file
INFO [2018-09-18 00:59:20] [awsmplace] Ongoing Unfollow [1/600]: now unfollowing 'b'insta1_follower''...
WARNING [2018-09-18 00:59:29] [awsmplace] --> Unfollow error! ~username 'awsmplace' might be blocked from unfollowing
WARNING [2018-09-18 00:59:29] [awsmplace] There is a serious issue: 'shadow ban'! ~leaving Unfollow-Users activity
INFO [2018-09-18 00:59:29] [awsmplace] --> Total people unfollowed : 0
INFO [2018-09-18 00:59:29] [awsmplace] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 0 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 2689 users & has got 1265 FOLLOWERS
I tried your solution 54e607c but doesn't work for me.
I'm pretty sure there's no shadow ban. I unfollowed successfully some profiles from desktop and mobile.
Any idea?
This is my unfollow script:
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=True,
multi_logs=False)
try:
session.login()
session.unfollow_users(amount=600, InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=1*60*60, sleep_delay=560)
except Exception as exc:
# if changes to IG layout, upload the file to help us locate the change
if isinstance(exc, NoSuchElementException):
file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
with open(file_path, 'wb') as fp:
fp.write(session.browser.page_source.encode('utf8'))
print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
'*' * 70, file_path))
# full stacktrace when raising Github issue
raise
finally:
# end the bot session
session.end()
Hi @tompicca
Thanks for reporting π¬
That issue was solved in the first commit- https://github.com/timgrossmann/InstaPy/pull/2901/commits/f5767d49f590d89a5926126d8a2e8b964210111b of that PR- #2901.
You can apply that commit _manually_ OR just pull from the master cos it is now _merged_.
Thanks for your reply @uluQulu π
I'm testing your code right now and I often get this error:
Timed out with failure while explicitly waiting until visibility of element located!
and sometimes:
"There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity
.
These warnings say something to you?
These are others strange behaviours:
--- instagram.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 134.874/134.874/134.874/0.000 ms
INFO [2018-09-18 12:23:12] [user] Checking if 'user' is logged in...
WARNING [2018-09-18 12:23:15] [user] Maybe 'b'yossra_______'' has changed the username! ~verifying through the user ID
INFO [2018-09-18 12:30:39] [user] User 'khristy_khristy' has changed username and now is called 'khristina_lorusso_' :S
INFO [2018-09-18 12:44:23] [user] --> Unfollowed 'khristy_khristy'!
You're welcome, @tompicca
...I often get this error:
"_Timed out with failure while explicitly waiting until visibility of element located!_"
Well, it is a helpful message to increase awareness.
...and sometimes:
"_There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity._"
It is a serious issue as it says β
...--- instagram.com ping statistics ---
It is pinging the server to check if there is a connectivity between the host and the server.
User 'khristy_khristy' has changed username and now is called 'khristina_lorusso_' :S
Now it can find the users according to their user ID stored in local files (thanks to @CharlesCCC) in case of they have changed the username from the last time you followed AND then unfollow THAT SAME USER with the new username π...
Having said ALL THOSE, I consider that you have applied the changes PROPERLY from that PR (_or so_) ππΌββοΈ
thanks for your reply @uluQulu,
I can report 3 profiles under InstaPy that are getting some issues, maybe can help you to find if there's a bug in the code:
User 1 issue: 'not connected'
ERROR [2018-09-18 14:15:21] [user1] --> Unable to detect the following status of 'b'dfert15''!
INFO [2018-09-18 14:15:21] [user1] Pinging 'instagram.com' to check the connectivity...
PING instagram.com (52.0.155.232): 56 data bytes
--- instagram.com ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
CRITICAL [2018-09-18 14:15:32] [user1] There is no connection to the 'instagram.com' server!
WARNING [2018-09-18 14:15:32] [user1] There is a serious issue: 'not connected'! ~leaving Unfollow-Users activity
INFO [2018-09-18 14:15:32] [user1] --> Total people unfollowed : 0
INFO [2018-09-18 14:15:32] [user1] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 0 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 3068 users & has got 5120 FOLLOWERS
User 2 issue: 'not logged in'
INFO [2018-09-18 12:53:53] [user2] Ongoing Unfollow [6/600]: now unfollowing 'b'face.padova''...
INFO [2018-09-18 12:55:11] [user2] Timed out with failure while explicitly waiting until visibility of element located!
INFO [2018-09-18 12:56:28] [user2] Timed out with failure while explicitly waiting until visibility of element located!
ERROR [2018-09-18 12:56:28] [user2] --> Unable to detect the following status of 'b'face.padova''!
INFO [2018-09-18 12:56:28] [user2] Pinging 'instagram.com' to check the connectivity...
PING instagram.com (34.234.205.165): 56 data bytes
64 bytes from 34.234.205.165: icmp_seq=0 ttl=234 time=134.304 ms
--- instagram.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 134.304/134.304/134.304/0.000 ms
INFO [2018-09-18 12:56:28] [user2] Checking if 'user2' is logged in...
CRITICAL [2018-09-18 12:56:31] [user2] --> 'user2' is not logged in!
WARNING [2018-09-18 12:56:31] [user2] There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity
INFO [2018-09-18 12:56:31] [user2] --> Total people unfollowed : 5
INFO [2018-09-18 12:56:31] [user2] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 5 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 2692 users & has got 3401 FOLLOWERS
User 3 issue: 'not logged in'
INFO [2018-09-18 11:13:59] [user3] Ongoing Unfollow [30/600]: now unfollowing 'b'yossra_______''...
INFO [2018-09-18 11:15:18] [user3] Timed out with failure while explicitly waiting until visibility of element located!
INFO [2018-09-18 11:16:35] [user3] Timed out with failure while explicitly waiting until visibility of element located!
ERROR [2018-09-18 11:16:35] [user3] --> Unable to detect the following status of 'b'yossra_______''!
INFO [2018-09-18 11:16:35] [user3] Pinging 'instagram.com' to check the connectivity...
INFO [2018-09-18 11:16:35] [user3] Checking if 'user3' is logged in...
CRITICAL [2018-09-18 11:16:38] [user3] --> 'user3' is not logged in!
WARNING [2018-09-18 11:16:38] [user3] There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity
INFO [2018-09-18 11:16:38] [user3] --> Total people unfollowed : 29
INFO [2018-09-18 11:16:38] [user3] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 29 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 3436 users & has got 5415 FOLLOWERS
For all these profiles I use the same script:
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=True,
multi_logs=False)
try:
session.login()
session.unfollow_users(amount=600, InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=1*60*60, sleep_delay=190)
I'm using headless browser so now I can't determine what happened to the browser during these errors but I can investigate π§
Also, I'm using the multiplexer screen
on my terminal to run multiple instagram accounts.
Hey @tompicca
CRITICAL [2018-09-18 14:15:32] [user1] There is no connection to the 'instagram.com' server!
Ping failed and it means there is no connection to the server.
Can you tell how frequently it happens? [each session, hourly, daily, always, sometimes [how frequently?]]
CRITICAL [2018-09-18 12:56:31] [user2] --> 'user2' is not logged in!
Same as previous;
Can you tell how frequently it happens? [each session, hourly, daily, always, sometimes [how frequently?]]
For login issue it is understandable and can be solved cos it says it is not logged in but actually it unfollowed a few people before- bug;
I will try to write a few more lines to handle it better.
Keep up feedbacks π¨πΌβπ»
@tompicca
To troubleshoot the login issue, please do this addition in your util.py file
except WebDriverException:
raise # ADD THIS NEW LINE
activity_counts = None
And then post the full console output [without personal information] to see the problem.
@uluQulu I have noticed similar issue, this might also related to the change I made to use the https://www.instagram.com/web/friendships/{user-id}/follow/
to get the username/profile page.
What I have seem is, if currently use this link, the instagram.com will prompt you to re-sign in again for whatever reason, even cookie already existed. we might have to revert those change back to the original method and figure out another better way to handle scenario that following user that has changed username.
Unfortunately I will not able to work too much on this matter recently as I'm having another long international business trip coming up tomorrow. If nobody got a chance to make the change before I get back, I will make sure get the fix when I got back.
β
@CharlesCCC
First after reading your post I tested and encountered that issue [log out] AND then prepared a solution for it and then tested for last time if your method really does not work and why does not work WHERE interestingly it turned out to work perfectly.
Now I can use https://www.instagram.com/web/friendships/{user-id}/follow/
without issues.
It makes me think there is an issue to be happened sometimes π€
What do you think?
Does it always log out in your side in [some account(s)]?
@uluQulu Well, I guess it is happening from time to time or only some accounts.(Also make sense that not everybody is reporting to the issue).
@uluQulu @CharlesCCC
As I told you all don't use thing that no normal person don't use.
https://www.instagram.com/web/friendships/{user-id}/follow/
is not normal.
The only case to use it is with fake robots and proxies.
Moreover:
DON'T PING Instagram server !
Maybe some dos attack log you out.
BTW I have 100's of accounts running with old repo and none get logged out.
@sionking
As I told you all don't use thing that no normal person don't use.
People are people. But if you run a search with https://www.instagram.com/web/friendships/{user-id}/follow/
keyword you can see WHO uses it.
And almost all of the of InstaPy sort of applications USE IT.
Is there a better?
Any alternatives?
But I really cannot find the issue with logging out with that method. Maybe while testing it earlier, I was not logged in and it seemed like the issue @CharlesCCC stated.
But it really must be verified, so that I can offer other 2 solutions.
@sionking
Pinging is a simple art π chill & also give a proof π¬
I think a better approach is to search the old username in the search box.
Think about this, user A; user B; after a while user A changed username to ABC and user B changed username to user A;
So if you try to search for user A it will find user B - NOT A SOLUTION;
Working with user ID is 100% accurate.
Well guys, having not heard any feedback from the issue raisers, it is gonna be another issue without a solution.
@tompicca can you invest some time into this? π
But I have a hint that can make a problem with log in issue.
It is kind of checking the activity_counts
before the page loads or not loads properly.
I will add some handles to it to stabilize expressions.
@sionking
BTW I have 100's of accounts running with old repo and none get logged out.
[old repo] was full of bugs that I solved and this is the another bug; remember that these sets of blocks are out of your hands- verification π
Also, the user being logged out is not proved yet, I think it is another issue, we will see it after feedbacks (if any).
Hi guys, sorry for my late reply.
I let my accounts sleep for 3 days and now, using always the same method:
try:
n = 0
session.login()
while n <= 10:
session.unfollow_users(amount=30, InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=246060, sleep_delay=300)
n +1
time.sleep(10*60)
except WebDriverException:
raise # ADD THIS NEW LINE
activity_counts = None
finally:
session.end()
all runs smoothly.
My impression is that instagram had put my account in a different kind of ban that not concern follow/unfollow or like system but more probably about the ping request or something. I said this because when you are banned for follow/unfollow you can't obviously perform that particular action for 24h or more, but my accounts never had that kind of block. I suppose that these 3 days that I never used my account helped to reset the intagram ban.
For now my accounts are unfollowing smoothly and I'm using instapy updated at 3 days ago.
If I'll encount some issue I will update you here.
Keep up the good work!
[UPDATE]
Unfollowing is really fast and the log file flows great now. Is to possibile that instagram slow down instapy if suspects that a bot is driving the account?
Ok @uluQulu after some good unfollow sessions today, I started to get errors.
Firstly the log started to report this error for each of the user tried to unfollow:
INFO [2018-09-21 13:22:56] [user] Ongoing Unfollow [42/100]: now unfollowing 'b'martinacucchi''...
INFO [2018-09-21 13:22:59] [user] --> Couldn't unfollow 'b'martinacucchi''! ~maybe unfollowed before
INFO [2018-09-21 13:22:59] [user] Removed '2018-09-02 10:44 ~ martinacucchi ~ 558906737' from followedPool.csv file
After a quick check I noticed that all these users are still followed by my account or are under request of following so InstaPy is wrong when says that the user is maybe unfollowed before
After lots of this errors Instapy stop working and report a not logged in
error when try to evaluate a user that changed its username:
INFO [2018-09-21 13:23:18] [user] Ongoing Unfollow [42/100]: now unfollowing 'b'_nena.mala_''...
INFO [2018-09-21 13:24:37] [user] Timed out with failure while explicitly waiting until visibility of element located!
INFO [2018-09-21 13:25:54] [user] Timed out with failure while explicitly waiting until visibility of element located!
ERROR [2018-09-21 13:25:54] [user] --> Unable to detect the following status of 'b'_nena.mala_''!
INFO [2018-09-21 13:25:54] [user] Pinging 'instagram.com' to check the connectivity...
INFO [2018-09-21 13:25:54] [user] Checking if 'user' is logged in...
CRITICAL [2018-09-21 13:25:58] [user] --> 'user' is not logged in!
WARNING [2018-09-21 13:25:58] [user] There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity
INFO [2018-09-21 13:25:58] [user] --> Total people unfollowed : 41
Then I run again InstaPy a couple of times but I always got the same error:
INFO [2018-09-21 13:35:58] [user] Starting to unfollow users..
INFO [2018-09-21 13:35:58] [user] Unfollowing the users followed by InstaPy
INFO [2018-09-21 13:35:58] [user] Total 2464 users available to unfollow ~didn't pass unfollow_after: 0
INFO [2018-09-21 13:35:58] [user] Ongoing Unfollow [1/100]: now unfollowing 'b'_nena.mala_''...
INFO [2018-09-21 13:37:17] [user] Timed out with failure while explicitly waiting until visibility of element located!
INFO [2018-09-21 13:38:34] [user] Timed out with failure while explicitly waiting until visibility of element located!
ERROR [2018-09-21 13:38:34] [user] --> Unable to detect the following status of 'b'_nena.mala_''!
INFO [2018-09-21 13:38:34] [user] Pinging 'instagram.com' to check the connectivity...
PING instagram.com (52.206.180.129): 56 data bytes
64 bytes from 52.206.180.129: icmp_seq=0 ttl=234 time=133.971 ms
--- instagram.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 133.971/133.971/133.971/0.000 ms
INFO [2018-09-21 13:38:34] [user] Checking if 'user' is logged in...
CRITICAL [2018-09-21 13:38:37] [user] --> 'user' is not logged in!
WARNING [2018-09-21 13:38:37] [user] There is a serious issue: 'not logged in'! ~leaving Unfollow-Users activity
INFO [2018-09-21 13:38:37] [user] --> Total people unfollowed : 0
Here is the full log.
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
Most helpful comment
Hello @meinert
It is another bug π
Thanks for raising!
Gonna share a solution soon π
UPDATE:
The solution- https://github.com/timgrossmann/InstaPy/pull/2901/commits/54e607c84ff50a5d60a4ca7f88bf8f7517832404 is shared at #2901 PR https://github.com/timgrossmann/InstaPy/pull/2901#issuecomment-421847088.
_Now it should solve your problems_.
IF not works as expected, let me know ππΌπ¨πΌβπ»
Cheers π