Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed363ff

Browse files
committed
Add a ChatGPT example
1 parent e86e07c commit ed363ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎examples/cdp_mode/raw_chatgpt.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from seleniumbase import SB
2+
3+
with SB(uc=True, test=True, ad_block=True) as sb:
4+
url = "https://chatgpt.com/"
5+
sb.activate_cdp_mode(url)
6+
query = "Compare Playwright to SeleniumBase in under 178 words"
7+
sb.type("#prompt-textarea", query)
8+
sb.click('button[data-testid="send-button"]')
9+
print('Input for ChatGPT:\n"%s"' % query)
10+
sb.sleep(12)
11+
chat = sb.find_element('[data-message-author-role="assistant"] .markdown')
12+
soup = sb.get_beautiful_soup(chat.get_html()).get_text("\n").strip()
13+
print("Response from ChatGPT:\n%s" % soup.replace("\n:", ":"))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /