Open iwaitu opened 1 year ago
yes, today pychatgpt doesn't work....very sad
Are there any solutions? I think there will be a way as long the webpage chatGPT is available?
Here's a quick solution that works for me, replace the line in pyChatGPT.py:
chatgpt_login_btn = (By.XPATH, '//button[text()="Log in"]')
with:
chatgpt_login_btn = (By.XPATH, '//button[contains(div, "Log in")]')
Changing chatgpt_login_btn did not work for me.
pyChatGPT successfully navigates past login, successfully runs my message, and then fails. It looks like it fails when running EC.element_to_be_clickable(chatgpt_chats_list_first_node), Possibly, the name on the page output by ChatGPT changed.
For anyone strugling to make it work i figured we have to set cf_clearance
cookie in order for it to work i wrote my own script based on the codebase you can use it to make it work for your own use case accordingly
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as SeleniumExceptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as SeleniumExceptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import undetected_chromedriver as uc
from markdownify import markdownify
from threading import Thread
import platform
import logging
import weakref
import json
import time
import re
import os
import time
driver = uc.Chrome()
def init(email,password):
driver.execute_cdp_cmd(
'Network.setBlockedURLs',
{'urls': ['https://chat.openai.com/backend-api/moderations']},
)
driver.get('https://chat.openai.com/')
chatgpt_login_btn = (By.XPATH, '//button[div[text()="Log in"]]')
chatgpt_username_input=(By.XPATH,'//input[@id="username"]')
chatgpt_password_input=(By.XPATH,'//input[@id="password"]')
chatgpt_continue_button=(By.XPATH,'//button[text()="Continue"]')
driver.execute_cdp_cmd(
'Network.setCookie',
{
'domain': 'chat.openai.com',
'path': '/',
'name': 'cf_clearance',
'value': 'copy from cookies',
'httpOnly': True,
'secure': True,
},
)
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(chatgpt_login_btn)
).click()
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(chatgpt_username_input)
).send_keys(email)
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(chatgpt_continue_button)
).click()
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(chatgpt_password_input)
).send_keys(password)
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(chatgpt_continue_button)
).click()
# driver.get('https://chat.openai.com/api/auth/session')
init('myemail@gmail.com','password')
# add your own logic of making request and getting response
time.sleep(20)
I have upgraded Chrome to version 111 as instructed by the error message, but it still doesn't work.