benmanns / cleverbot

Deprecated/unmaintained. See https://www.cleverbot.com/api/
https://github.com/benmanns/cleverbot
MIT License
22 stars 19 forks source link

All requests are getting 404'd #7

Closed Xaekai closed 3 years ago

Xaekai commented 9 years ago

As per title, this module has stopped working for me. I presume it is due to changes made on Cleverbot's end.

yousefamar commented 9 years ago

Same here. And same goes for https://github.com/fojas/cleverbot-node so it is indeed probably because of changes on Cleverbot's end.

jalada commented 9 years ago

:+1: might take a look.

benmanns commented 9 years ago

I've updated the default parameters to match the current request structure. There's also a new XVIS cookie that will need to be set before requests to /webservicemin occur. Once, I write a good way to get that cookie before requests I'll push out a new version.

jalada commented 9 years ago

@benmanns I am in absolutely no way saying my solution is right; it was pretty hacky, but feel free to take a look for inspiration/to steal: https://github.com/jalada/cleverbot/commit/75717384e88739eea1d8b8af8635f9dfa74309ad

Not submitting a pull request because I also mucked around with gems, headers etc. but the cookie management is the key change.

(And it works, so far)

william-bratches commented 9 years ago

This probably isn't useful, but I whipped together a selenium test in python that can be used with a headless browser to get a simple call/response to cleverbot. Just a hack until hopefully this api business gets sorted out...

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

# use phantomJS here for invisible browser
#driver = webdriver.PhantomJS()

#or plain old firefox
driver = webdriver.Firefox()

driver.get("http://www.cleverbot.com")

def send_message():

    # prompt user for text
    message = raw_input('Enter a message:')

    # set value of text box
    driver.find_element_by_class_name('stimulus').send_keys(message)

    # hit send
    driver.find_element_by_class_name('sayitbutton').click()

    # get cleverbot output
    time.sleep(5) # takes a moment for text to appear on screen...which sucks
    sentences = driver.find_elements_by_xpath('.//span[@class = "bot"]')
    print sentences[len(sentences) - 1].text

    send_message()

send_message()