Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -95,7 +95,17 @@ def get_data_from_url(url):
|
|
| 95 |
(using raw Google model) to extract grant data in a JSON structure.
|
| 96 |
"""
|
| 97 |
try:
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
page_content = web_content.content
|
| 100 |
full_prompt = (
|
| 101 |
"Extract the following grant data from the provided web content. "
|
|
@@ -138,6 +148,7 @@ def get_data_from_url(url):
|
|
| 138 |
return {}
|
| 139 |
|
| 140 |
|
|
|
|
| 141 |
def process_multiple_search_terms(search_terms):
|
| 142 |
"""
|
| 143 |
Process multiple search terms with progress tracking.
|
|
|
|
| 95 |
(using raw Google model) to extract grant data in a JSON structure.
|
| 96 |
"""
|
| 97 |
try:
|
| 98 |
+
# Try using the supadata.web.scrape method
|
| 99 |
+
try:
|
| 100 |
+
web_content = supadata.web.scrape(url)
|
| 101 |
+
except TypeError as te:
|
| 102 |
+
# Fallback if an unexpected keyword argument 'type' is raised
|
| 103 |
+
if "unexpected keyword argument 'type'" in str(te):
|
| 104 |
+
st.warning("Falling back to alternative scraping method due to unexpected keyword argument 'type'.")
|
| 105 |
+
web_content = supadata.scrape(url)
|
| 106 |
+
else:
|
| 107 |
+
raise te
|
| 108 |
+
|
| 109 |
page_content = web_content.content
|
| 110 |
full_prompt = (
|
| 111 |
"Extract the following grant data from the provided web content. "
|
|
|
|
| 148 |
return {}
|
| 149 |
|
| 150 |
|
| 151 |
+
|
| 152 |
def process_multiple_search_terms(search_terms):
|
| 153 |
"""
|
| 154 |
Process multiple search terms with progress tracking.
|