返回提交历史
Modified
g4f/Provider/needs_auth/Grok.py
+20
-6
XFEstudio/gpt4free
Improve input handling in Grok.py
Refactor input selection and submission logic for better error handling and clarity.
05c108d3
代码差异
1 个文件
+20
-6
@@ -92,12 +92,26 @@ class Grok(AsyncAuthedProvider, ProviderModelMixin):
92
92
while True:
93
93
if has_headers:
94
94
break
95
textarea = await page.select("textarea", 180)
96
await textarea.send_keys("Hello")
97
await asyncio.sleep(1)
98
button = await page.select("button[type='submit']")
99
if button:
100
await button.click()
95
input_element = None
96
try:
97
input_element = await page.select("div.ProseMirror", 2)
98
except Exception:
99
pass
100
if not input_element:
101
try:
102
input_element = await page.select("textarea", 180)
103
except Exception:
104
pass
105
if input_element:
106
try:
107
await input_element.click()
108
await input_element.send_keys("Hello")
109
await asyncio.sleep(0.5)
110
submit_btn = await page.select("button[type='submit']", 2)
111
if submit_btn:
112
await submit_btn.click()
113
except Exception:
114
pass
101
115
await asyncio.sleep(1)
102
116
auth_result.cookies = {}
103
117
for c in await page.send(nodriver.cdp.network.get_cookies([cls.url])):