Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,17 @@ def websearch(prompt):
|
|
34 |
headers = {
|
35 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
36 |
}
|
37 |
-
url = f"https://www.googleapis.com/customsearch/v1?key={google_api_key}&cx={cx}&q={prompt}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
response = requests.get(url, headers=headers)
|
40 |
data = response.json() # JSON-Daten direkt verarbeiten
|
|
|
34 |
headers = {
|
35 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
36 |
}
|
37 |
+
#url = f"https://www.googleapis.com/customsearch/v1?key={google_api_key}&cx={cx}&q={prompt}"
|
38 |
+
url = f"https://www.google.com/search?key={google_api_key}&cx={cx}&q={prompt}"
|
39 |
+
|
40 |
+
response = requests.get(url, headers=headers)
|
41 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
42 |
+
response_text = soup.find('body')
|
43 |
+
#prompt = f"{search_term}\n use this result from a google search to answer the question \n {response_text.text}"
|
44 |
+
#result = predict(prompt)
|
45 |
+
return response_text.text
|
46 |
+
|
47 |
+
|
48 |
|
49 |
response = requests.get(url, headers=headers)
|
50 |
data = response.json() # JSON-Daten direkt verarbeiten
|