Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script crashes after 1st iteration of views #23

Open
antsuca opened this issue Jun 13, 2023 · 2 comments
Open

Script crashes after 1st iteration of views #23

antsuca opened this issue Jun 13, 2023 · 2 comments

Comments

@antsuca
Copy link

antsuca commented Jun 13, 2023

First iteration of views is working, 1000 views are send and then the code crashes with the bellow error. Is there a fix for this? Tnx

File "/ home/da/zefoy/main.py", line 106, in main self.send_bot(search_box, video_url_box, vid_info, div)
File "/home/da/zefoy/matn.py", line 124, in send bot self.driver.find_element ('xpath', send button). click()
File " home /da/ . Local/lib/python3.10/site-packages/selenium/webdriver /remot e/webdriver-py", line 861, in find_element
return self .execute (Command. FIND_ELEMENT, {"using": by, "value": value}) ["v alue"]
File " / home/da/.local/lib/python3.10/site-packages/selentum/webdriver/remot e/webdriver .py" line 444, in execute
self.error_ handler.check_response (response)
File " / home/da/.local/lib/python3.10/site-packages/selenium/webdriver/remot e/errorhandler-py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions. NoSuchElementException: Message: no such element: Un able to locate element: {"method": "xpath"
"selector":" /html/body/div[10]/div/di
v/div[1]/div/form/button" }
(Session info: chrome=114.0.5735.106)
Stacktrace:
#0 0×55d1adde74e3
#1 0x55d1adb16c76
#2 0x55d1adb52c96
#3 0x55d1adb52dc1
#4 0x55d1adb8c7f4
#5 0x55d1adb7203d

@Alroha
Copy link

Alroha commented Jun 15, 2023

Chang to send_bot function to this:

def send_bot(self, search_button, main_xpath, vid_info, div):
    try:
        element = self.driver.find_element('xpath', main_xpath)
        element.clear()
        element.send_keys(vid_info)
        self.driver.find_element('xpath', search_button).click()
        time.sleep(3)

        ratelimit_seconds, full = self.check_submit(div)
        if "(s)" in str(full):
            self.main_sleep(ratelimit_seconds)
            self.driver.find_element('xpath', search_button).click()
            time.sleep(2)

        time.sleep(3)

        send_button = f'/html/body/div[{div}]/div/div/div[1]/div/form/button'
        self.driver.find_element('xpath', send_button).click()
        self.sent += 1
        print(self._print(f"Sent {self.sent} times."))

        time.sleep(4)
        self.send_bot(search_button, main_xpath, vid_info, div)


    except Exception as e:
        os.system(self.clear)  # Clear the console
        self.trys += 1
        print(Fore.WHITE+"["+Fore.RED+"!"+Fore.WHITE+f'] FAILED TO SEND - {self.trys}')
        self.send_bot(search_button, main_xpath, vid_info, div)

And change init fuction to this

def __init__(self):
    self.driver      = uc.Chrome()
    self.captcha_box = '/html/body/div[5]/div[2]/form/div/div'
    self.clear       = "clear"
    
    if platform.system() == "Windows":
        self.clear = "cls"
    
    self.color  = Fore.BLUE
    self.sent   = 0
    self.trys   = 0
    self.xpaths = {
        "followers"     : "/html/body/div[6]/div/div[2]/div/div/div[2]/div/button",
        "hearts"        : "/html/body/div[6]/div/div[2]/div/div/div[3]/div/button",
        "comment_hearts": "/html/body/div[6]/div/div[2]/div/div/div[4]/div/button",
        "views"         : "/html/body/div[6]/div/div[2]/div/div/div[5]/div/button",
        "shares"        : "/html/body/div[6]/div/div[2]/div/div/div[6]/div/button",
        "favorites"     : "/html/body/div[6]/div/div[2]/div/div/div[7]/div/button",
    }

@Jlacerte123
Copy link

^ This fixed the issue, thank you so much!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants