danielgross / whatsapp-gpt

MIT License
3.07k stars 596 forks source link

page_elements = PAGE.query_selector_all(".flex.flex-col.items-center > div") changed #79

Open MeinDeutschkurs opened 1 year ago

MeinDeutschkurs commented 1 year ago

Yes it changed, but I'm not able to figure the correct one out, so currently I reload "new chat", and I take

page_elements = PAGE.query_selector_all(".flex.flex-col.items-start > div")

instead, with last_element = page_elements[0] instead of -2.

MeinDeutschkurs commented 1 year ago

Ok, GOT it. This works (same chat history)

page_elements = PAGE.query_selector_all("div.group.w-full")
last_element = page_elements[-1]
return last_element.inner_text()

I reload the browser window every time before injecting the prompt. This avoids error 500 after two hours.

def send_message(message):
# Send the message
# Refresh the page before sending the message
time.sleep(2)
PAGE.reload()
# Wait for 5 seconds - because of longer history
time.sleep(5)
# Send the message
box = get_input_box()
box.click()