alexal1 / Insomniac

Instagram bot for automated Instagram interaction using Android device via ADB
https://insomniac-bot.com
MIT License
688 stars 159 forks source link

Loop using recent-likers #252

Open soulpawa opened 3 years ago

soulpawa commented 3 years ago

the phone starts to scroll down, and is trying to find posts, the pots are there but the bot is not detecting them, and then starts this loop of error, never ends:

[01/17 23:26:56] No idea what it was. Let's try again. [01/17 23:26:56] Close Instagram app [01/17 23:26:57] Sleep for 2.40 seconds [01/17 23:26:59] Open Instagram app [01/17 23:27:00] Sleep for 2.76 seconds [01/17 23:27:03] Press profile [01/17 23:27:03] Closing keyboard... [01/17 23:27:03] The device keyboard is already closed. [01/17 23:27:08] Interacting with #shavingcream-recent-likers [01/17 23:27:08] Closing keyboard... [01/17 23:27:08] The device keyboard is already closed. [01/17 23:27:11] Sleep for 1.90 seconds [01/17 23:27:14] Sleep for 2.36 seconds [01/17 23:27:18] Switching to Recent tab [01/17 23:27:23] Can't Find recent tab. Interacting with Popular. [01/17 23:27:23] Sleep for 2.07 seconds [01/17 23:27:25] Opening post #13 [01/17 23:27:27] Cannot find post #13. Swiping down a bit. [01/17 23:27:30] Cannot find post #13. Swiping down a bit. [01/17 23:27:34] Cannot find post #13. Swiping down a bit. [01/17 23:27:37] Cannot find post #13. Swiping down a bit. [01/17 23:27:40] Cannot find post #13. Swiping down a bit. [01/17 23:27:44] Cannot find post #13. Swiping down a bit. [01/17 23:27:47] Cannot find post #13. Swiping down a bit. [01/17 23:27:50] Cannot find post #13. Swiping down a bit. [01/17 23:27:54] Cannot find post #13. Swiping down a bit. [01/17 23:27:57] Cannot find post #13. Swiping down a bit. [01/17 23:28:00] Cannot find post #13 after 10 swipes. Aborting. [01/17 23:28:07] Traceback (most recent call last): File "/home/pi/.local/lib/python3.7/site-packages/insomniac/device_facade.py", line 382, in click self.viewV2.click(UI_TIMEOUT_LONG, offset=(x_offset, y_offset)) File "/home/pi/.local/lib/python3.7/site-packages/uiautomator2/_selector.py", line 150, in click self.must_wait(timeout=timeout) File "/home/pi/.local/lib/python3.7/site-packages/uiautomator2/_selector.py", line 345, in must_wait raise UiObjectNotFoundError({'code': -32002, 'data': str(self.selector), 'method': 'wait'}) uiautomator2.exceptions.UiObjectNotFoundError: -32002 Client error: <> data: Selector [resourceId='com.instagram.android:id/image_button', className='android.widget.ImageView', index=13], method: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/pi/.local/lib/python3.7/site-packages/insomniac/safely_runner.py", line 14, in wrapper func(*args, **kwargs) File "/home/pi/.local/lib/python3.7/site-packages/insomniac/action_runners/interact/init.py", line 177, in job self.action_status) File "/home/pi/.local/lib/python3.7/site-packages/insomniac/action_runners/interact/action_handle_hashtag.py", line 226, in handle_hashtag on_action) File "/home/pi/.local/lib/python3.7/site-packages/insomniac/action_runners/interact/action_handle_hashtag.py", line 271, in extract_hashtag_profiles_and_interact post_view.click() File "/home/pi/.local/lib/python3.7/site-packages/insomniac/device_facade.py", line 384, in click raise DeviceFacade.JsonRpcError(e) insomniac.device_facade.DeviceFacade.JsonRpcError: -32002 Client error: <> data: Selector [resourceId='com.instagram.android:id/image_button', className='android.widget.ImageView', index=13], method: None

WARNING:root:HTTPConnectionPool(host='localhost', port=39457): Read timed out. (read timeout=10), retrying in 0.5 seconds... WARNING:root:HTTPConnectionPool(host='localhost', port=39457): Read timed out. (read timeout=10), retrying in 0.6 seconds... WARNING:root:HTTPConnectionPool(host='localhost', port=39457): Read timed out. (read timeout=10), retrying in 0.7 seconds... WARNING:root:HTTPConnectionPool(host='localhost', port=39457): Read timed out. (read timeout=10), retrying in 0.7999999999999999 seconds... [01/17 23:30:20] Crash saved as "crashes/Crash-2021-01-17-23-30-09.zip". [01/17 23:30:20] Please attach this file if you gonna report the crash at [01/17 23:30:20] https://github.com/alexal1/Insomniac/issues

the crash is not saved, so I can't attach anything.

simonmannsfeld commented 3 years ago

I don't know why the bot is crashing. But I know something about the "Swiping down a bit"-loop. Insomniac is getting randomly the post between 1-20 (for your case: post #13).

It looks like it depends on screen resolution how many posts will be rendered at the same time. In my case there will only be 18 posts rendered. If random function choose post 18, 19 or 20, I stuck in the same loop.

It should be great if someone could replace the static 20 from post_num = randint(first_post_index, 20) in /insomniac/action_runners/interact/action_handle_hashtag.py on line 255.

The attached screenshot shows up that there will be never more posts than 18 (0-17).

image

soulpawa commented 3 years ago

this is a very good point, and it makes a lot of sense since my screen is only showing 9 posts :(

IMG_0467

simonmannsfeld commented 3 years ago

@soulpawa Insomniac will scroll down, so maybe just 12 posts will be loaded.

What did you do with your smartphone? Are you thowing it at women?

soulpawa commented 3 years ago

I buy them broken for just 5 or $10 in propose for using with my raspberry and insomniac, I have 4 like that.

@soulpawa Insomniac will scroll down, so maybe just 12 posts will be loaded.

What did you do with your smartphone? Are you thowing it at women?

simonmannsfeld commented 3 years ago

@soulpawa Did you edited post_num = randint(first_post_index, 20) to 11 or 12? Does it work? Please let us know!

soulpawa commented 3 years ago

@soulpawa Did you edited post_num = randint(first_post_index, 20) to 11 or 12? Does it work? Please let us know!

didn't try yet, I'll change it and I will let you know.

soulpawa commented 3 years ago

I changed 20 for 10 and the problem is still there:

01/22 14:57:14] Closing keyboard... [01/22 14:57:14] The device keyboard is already closed. [01/22 14:57:17] Sleep for 1.50 seconds [01/22 14:57:20] Sleep for 2.74 seconds [01/22 14:57:23] Switching to Recent tab [01/22 14:57:28] Can't Find recent tab. Interacting with Popular. [01/22 14:57:28] Sleep for 2.87 seconds [01/22 14:57:31] Opening post #4 [01/22 14:57:33] Cannot find post #4. Swiping down a bit. [01/22 14:57:37] Cannot find post #4. Swiping down a bit. [01/22 14:57:40] Cannot find post #4. Swiping down a bit. [01/22 14:57:43] Cannot find post #4. Swiping down a bit. [01/22 14:57:46] Cannot find post #4. Swiping down a bit. [01/22 14:57:50] Cannot find post #4. Swiping down a bit. [01/22 14:57:53] Cannot find post #4. Swiping down a bit. [01/22 14:57:56] Cannot find post #4. Swiping down a bit. [01/22 14:57:59] Cannot find post #4. Swiping down a bit. [01/22 14:58:03] Cannot find post #4. Swiping down a bit. [01/22 14:58:06] Cannot find post #4 after 10 swipes. Aborting. ^C[01/22 14:58:11] Close Instagram app

I'll try later with a different phone

simonmannsfeld commented 3 years ago

First strage log is [01/22 14:57:28] Can't Find recent tab. Interacting with Popular.

Could you check for ìdandaccessibility name` of the recent tab?

You could use the app "Developer Assistant".

soulpawa commented 3 years ago

IMG_0477