plasticuproject / cleverbotfree

Free alternative for the Cleverbot API
GNU General Public License v3.0
58 stars 6 forks source link

Unable to locate element: .stimulus #15

Closed TGWaffles closed 3 years ago

TGWaffles commented 3 years ago

Running the usage example script in a regular python console returns the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in chat
  File "/usr/local/lib/python3.8/dist-packages/cleverbotfree/cbfree.py", line 129, in single_exchange
    self.get_form()
  File "/usr/local/lib/python3.8/dist-packages/cleverbotfree/cbfree.py", line 57, in get_form
    self.elem = self.browser.find_element_by_class_name('stimulus')
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
    return self.find_element(by=By.CLASS_NAME, value=name)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .stimulus
plasticuproject commented 3 years ago

It appears they made some changes to the website, breaking this. Working on a fix now. I think they might be detecting the use of selenium/webdriver now, and preventing stuff that needs to load on the page for us to communicate with the bot.

I've tried swapping geckodriver for chromedriver, using random User-Agents, time delaying clicks, etc. Can't seem to get anything to work. I may be forced to re-write this with pypupeteer instead of selenium.

plasticuproject commented 3 years ago

Working on a re-write using python-playwright. Tests seem to be working, will have a new version of this working soon.

plasticuproject commented 3 years ago

I re_wrote the module to use playwright instead of selenium. I think everything should be working now, I did some minimal testing. This introduces some breaking changes to the modules use, but it's the best I can do. Please let me know if you find any issues with the new code in a new issue, as I'll be closing this out now.