InstaPy / InstaPy

📷 Instagram Bot - Tool for automated Instagram interactions
GNU General Public License v3.0
16.85k stars 3.77k forks source link

"Image Liked" or "Now following" but not actually #1083

Closed espipj closed 5 years ago

espipj commented 6 years ago

I'm having this issue since the first execution. The script goes through the tags, picks photos, check if the user is appropiate (sometimes it isnt) and likes (follows 10% of them). It says "Image Liked" or "Now following" but when I go to Instagram browser or app the image/profile is not actually liked/followed.

I've gone further in my tests, after the script ends I run it again, but before of that I follow manually from mobile any of the users "supposedly followed" (not actually). The script starts unfollowing the list of follows of the previous execution, most of them arent followed so it catches the error unfollowing, but the one/s I followed manually prints by the log the unfollow, and the unfollow shows in the app/browser as well (unfollow works).

I dont really know what the problem is.

I'm running it headless+firefox+gecko on a Raspberry Pi 3 (same IP as my Mobile/PC) if it helps.

And the script I'm running is:

InstaPy(username='', password='',nogui=True, use_firefox=True, page_delay=25)\ .set_switch_language(False)\ .login()\ .set_do_comment(True, percentage=0) \ .set_comments(['Cool!', 'Awesome!', 'Nice!']) \ .set_do_follow(enabled=True, percentage=15, times=2) \ .set_dont_like(['food', 'girl', 'hot','NSFW']) \ .unfollow_users(amount=10, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=60 ) \ .set_upper_follower_count(limit=1500) \ .set_lower_follower_count(limit = 110) \ .like_by_tags(['traveler','canon'], amount=18) \ .end()

sionking commented 6 years ago

Is it working manually from the web? Don't change windows size.

davidrocket commented 6 years ago

Just catch the same problem today and I'm not sure if the problem has been there already for some time!

After changing the setup from Chrome to Firefox, both Headless!

I can confirm for a normal run (like_by_tags()...): -> Image liked! (NOT working) -> Commented "..." (working) -> Now following (NOT working)

instapy (on Firefox) has also problem with UNFOLLOWING. It's simply not working!

espipj commented 6 years ago

Hey @davidrocket I think UNFOLLOWING is actually working, but as It didnt actually followed fails in "unfollowing" as you cannot unfollow a profile you are not following ;) (if you follow (manually web/app one of the "false" following logged on the script, it will do the unfollow)

Which is the config where you are running the script in? Raspberry Pi? Has it worked before on Chrome in the RasPi? I might consider switching.

@sionking yes, its working manually from the web for sure. I had to change windows size in the instapy.py file as the script was throwing an "out of bounds exception", similar to #803

davidrocket commented 6 years ago

Unfollowing shows me this error on Firefox, with: session.unfollow_users(amount=count, onlyInstapyFollowed=False, onlyInstapyMethod='FIFO'))

Will raise the following error: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[text()='Following']/following-sibling::div

If Chrome is in used instead of Firefox with the same version of instapy, selenium and python, UNFOLLOWING will work!

davidrocket commented 6 years ago

UNFOLLOWING works now with Firefox (after tweaking around :) )! despite having this ERROR shown:

ERROR - set_automated_followed_pool error list index out of range

This Error indicates, this line failed:

with open('./logs/' + username + '_followedPool.csv') as \ followedPoolFile:

in my case, I actually dont have the file "username_followedPool.csv"... @converge After the file was created, it has its "row[0]" EMPTY, so the ERROR keeps raising! I hope, you guys with more insight can fix it easily! Thanks...

davidrocket commented 6 years ago

To Fix "Like"-Problem, please replace the line 537 in like_util.py with this line

like_elem[0].click()

Tested and works!

davidrocket commented 6 years ago

To Fix "Follow"-Problem, please replace the line 347 in unfollow_util.py with this line

follow_button.click()

Tested and works!

espipj commented 6 years ago

Hey @davidrocket Could you explain what environment are you using? (firefox/chrome, headless?, gecko driver version, selenium version, python version)

I'll test those fixes you say and give you feedback this weekend. ;)

espipj commented 6 years ago

@davidrocket You were right! It's working right now. I suggest @timgrossmann to change it but ¿it may not work in other environments?

Changing in these lines .send_keys("\n") by .click(): https://github.com/timgrossmann/InstaPy/blob/master/instapy/unfollow_util.py#L341

https://github.com/timgrossmann/InstaPy/blob/master/instapy/like_util.py#L537

davidrocket commented 6 years ago

For these 2 particular usecases, there will be no problem in any environment, as the items are clickable objects.

send_keys event can be used in place where text, images are put in and there are a predefined event-handler for "\n"-key.

davidrocket commented 6 years ago

Guys: please change the xpath selector of 'Like'-element in like_util.py at the following line:

"//a[@role='button']/span[text()='Like']/..")

to "//a[@role='button']/span[text()='Like']")

Abzidian commented 6 years ago

@davidrocket , did you find a solution to the followedPool.csv issue?

davidrocket commented 6 years ago

Try not to overwrite (keep) the instapy/db folder every time you update instapy to newer version!

converge commented 6 years ago

we need to overwrite database everytime we have database improvements, write new code to non existent database table is not a good idea.

davidrocket commented 6 years ago

We will also have inconsistent database of instagram account, when the one old overwritten by the new "but empty" one! I would try avoid replacing the older database files if they do still work!

converge commented 6 years ago

you will only overwrite your database if you don´t what you´re doing.

davidrocket commented 6 years ago

Let do some additional elaboration in what you want to say... Without looking into the code, one can say, It makes nosense to have a database for runtime, then being replaced by the new empty one!

eduaero commented 6 years ago

@davidrocket thank you very much for the solutions!! I would like to ask you how did u tweak around the code to solve the issue of unfollowing

I am stucked wih the following error that you mentioned: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[text()='Following']/following-sibling::div

What did you write instead of div[text()='Following']/following-sibling::div

Thank you very much beforehand!!

:)

davidrocket commented 6 years ago

Guys, I actually solve the problem somehow on my own branch! But it was a month at least... But a hint to the community is, please try to remove quotes (single, double) from your comments list, and do a check if they work! As I guess, the place where the instapy stops, is when it tries to put a comment on the media!

stale[bot] commented 5 years ago

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