redianmarku / Instagram-Multi-Feature-Bot

A python instagram selenium bot that can scrape most recents posts, usernames, send DMs or comment on these posts.
54 stars 22 forks source link

Anyone help-me with this error? #4

Open mendokismo opened 1 year ago

mendokismo commented 1 year ago

The bot works correctly in firsts parts of login and choose of hashtag... but crash in select the post and show this message error

Traceback (most recent call last): File "C:\Users\PC\Desktop\Instagram-Multi-Feature-Bot-master\run.py", line 91, in main() File "C:\Users\PC\Desktop\Instagram-Multi-Feature-Bot-master\run.py", line 84, in main post_links2 = bot.scrape_hashtag_posts(hashtag=args.hashtag) File "C:\Users\PC\Desktop\Instagram-Multi-Feature-Bot-master\InstagramBot.py", line 49, in scrape_hashtag_posts most_recent = self.driver.find_element(By.XPATH, '//div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/main/article/div[2]/div') File "C:\Users\PC\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 740, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] File "C:\Users\PC\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute self.error_handler.check_response(response) File "C:\Users\PC\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_respon se raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div/div/div[ 2]/div/div/div/div[1]/div[1]/div[2]/section/main/article/div[2]/div"} (Session info: chrome=114.0.5735.199); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troublesho oting/errors#no-such-element-exception Stacktrace: Backtrace: GetHandleVerifier [0x010EA813+48355] (No symbol) [0x0107C4B1] (No symbol) [0x00F85358] (No symbol) [0x00FB09A5] (No symbol) [0x00FB0B3B] (No symbol) [0x00FDE232] (No symbol) [0x00FCA784] (No symbol) [0x00FDC922] (No symbol) [0x00FCA536] (No symbol) [0x00FA82DC] (No symbol) [0x00FA93DD] GetHandleVerifier [0x0134AABD+2539405] GetHandleVerifier [0x0138A78F+2800735] GetHandleVerifier [0x0138456C+2775612] GetHandleVerifier [0x011751E0+616112] (No symbol) [0x01085F8C] (No symbol) [0x01082328] (No symbol) [0x0108240B] (No symbol) [0x01074FF7] BaseThreadInitThunk [0x771B60C9+25] RtlGetAppContainerNamedObjectPath [0x779C7A94+228] RtlGetAppContainerNamedObjectPath [0x779C7A64+180]

Sonusony201 commented 1 year ago

download bot zip again

Sonusony201 commented 1 year ago

Exception in Tkinter callback Traceback (most recent call last): File "C:\Python311\Lib\tkinter__init.py", line 1948, in call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 554, in _clicked self._command() File "E:\auto coment\Instagram-Multi-Feature-Bot-master\run.py", line 139, in start_bot post_links = bot.scrape_hashtag_posts(hashtag=hashtag) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\auto coment\Instagram-Multi-Feature-Bot-master\InstagramBot.py", line 49, in scrape_hashtag_posts most_recent = self.driver.find_element(By.XPATH, '//div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/main/article/div[2]/div') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 740, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute self.error_handler.check_response(response) File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/section/main/article/div[2]/div"} (Session info: chrome=114.0.5735.199); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception Stacktrace: Backtrace: GetHandleVerifier [0x00D6A813+48355] (No symbol) [0x00CFC4B1] (No symbol) [0x00C05358] (No symbol) [0x00C309A5] (No symbol) [0x00C30B3B] (No symbol) [0x00C5E232] (No symbol) [0x00C4A784] (No symbol) [0x00C5C922] (No symbol) [0x00C4A536] (No symbol) [0x00C282DC] (No symbol) [0x00C293DD] GetHandleVerifier [0x00FCAABD+2539405] GetHandleVerifier [0x0100A78F+2800735] GetHandleVerifier [0x0100456C+2775612] GetHandleVerifier [0x00DF51E0+616112] (No symbol) [0x00D05F8C] (No symbol) [0x00D02328] (No symbol) [0x00D0240B] (No symbol) [0x00CF4FF7] BaseThreadInitThunk [0x74D27D59+25] RtlInitializeExceptionChain [0x7707B74B+107] RtlClearBits [0x7707B6CF+191]

Exception ignored in: <function Chrome.del at 0x000001DCBCCC1620> Traceback (most recent call last): File "C:\Python311\Lib\site-packages\undetected_chromedriver__init.py", line 793, in del__ self.quit() File "C:\Python311\Lib\site-packages\undetected_chromedriver__init__.py", line 748, in quit time.sleep(0.1) OSError: [WinError 6] The handle is invalid

.

.

showing same thing again

mendokismo commented 1 year ago

download bot zip again

not work yet

JithinJose555 commented 1 year ago

Same problem here. As far as I can understand, Instagram changed after making this code and that's making a lot of issues. I saw a lot of problems in my debugger. As I'm not an expert, I don't know how to change it.

Sonusony201 commented 1 year ago

Please make code for android termux, maybe it will works!? Because android havs some apps like (insta pro, insta pro 2, Instender) hope it will works.

TheGreatSimo commented 1 year ago

Ok guys I will do A PR to fix those broken Xpaths

goddousoop commented 9 months ago

this is happening because instagram changing xpath of that div dynamically so its hard to track (id="mount_0_0_T2") in this every time you copy xpath the T2 character changes. we need to wait until it again comes T2. so remove the '#' from wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="mount_0_0_R4"]/div/div/div[2]/div/div/div[1]/div[1]/div[2]/section/main/article/div/div')))

and change the time to 10 to 10000 and wait for 10000 sec if you are lucky you get xpath

planted101 commented 7 months ago

Facing the same issue. Based on what [goddousoop] said, the code needs to be modified to find an alternative to the dynamic path in order for it to work.

felixvoir commented 6 months ago

On reddit someone says use dynamic command ->> self.driver.find_element_by_class_name("_6VtSN").click() But when i use this selenium gives error and says

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element

if i downgrade the selenium version it may work i will let you know.