mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-19 03:25:32 +00:00
Update Phind.py
This commit is contained in:
parent
aa12716974
commit
e0541c513f
@ -26,10 +26,6 @@ class Phind(BaseProvider):
|
|||||||
hidden_display: bool = True,
|
hidden_display: bool = True,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> CreateResult:
|
) -> CreateResult:
|
||||||
from selenium.webdriver.common.by import By
|
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
|
||||||
|
|
||||||
if browser:
|
if browser:
|
||||||
driver = browser
|
driver = browser
|
||||||
else:
|
else:
|
||||||
@ -38,6 +34,10 @@ class Phind(BaseProvider):
|
|||||||
else:
|
else:
|
||||||
driver = get_browser("", False, proxy)
|
driver = get_browser("", False, proxy)
|
||||||
|
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
|
||||||
prompt = quote(format_prompt(messages))
|
prompt = quote(format_prompt(messages))
|
||||||
driver.get(f"{cls.url}/search?q={prompt}&source=searchbox")
|
driver.get(f"{cls.url}/search?q={prompt}&source=searchbox")
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ class Phind(BaseProvider):
|
|||||||
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".search-container")))
|
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".search-container")))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Fetch hook
|
||||||
script = """
|
script = """
|
||||||
window._fetch = window.fetch;
|
window._fetch = window.fetch;
|
||||||
window.fetch = (url, options) => {
|
window.fetch = (url, options) => {
|
||||||
@ -78,7 +79,7 @@ window.fetch = (url, options) => {
|
|||||||
if(window.reader) {
|
if(window.reader) {
|
||||||
chunk = await window.reader.read();
|
chunk = await window.reader.read();
|
||||||
if (chunk['done']) return null;
|
if (chunk['done']) return null;
|
||||||
text = await (new Response(chunk['value']).text());
|
text = (new TextDecoder()).decode(chunk['value']);
|
||||||
content = '';
|
content = '';
|
||||||
text.split('\\r\\n').forEach((line, index) => {
|
text.split('\\r\\n').forEach((line, index) => {
|
||||||
if (line.startsWith('data: ')) {
|
if (line.startsWith('data: ')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user