Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -22,18 +22,9 @@ import time
|
|
| 22 |
|
| 23 |
@app.get("/get_scraped_data")
|
| 24 |
async def get_data(url: str):
|
| 25 |
-
|
| 26 |
-
start_time = time.time()
|
| 27 |
-
#try:
|
| 28 |
data = await Scraper.scrape(url)
|
| 29 |
-
# End time
|
| 30 |
-
end_time = time.time()
|
| 31 |
-
|
| 32 |
-
# Calculate the elapsed time
|
| 33 |
-
elapsed_time = end_time - start_time
|
| 34 |
-
|
| 35 |
-
print(f"Time taken for the process: {elapsed_time:.2f} seconds")
|
| 36 |
return data
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
|
|
|
| 22 |
|
| 23 |
@app.get("/get_scraped_data")
|
| 24 |
async def get_data(url: str):
|
| 25 |
+
try:
|
|
|
|
|
|
|
| 26 |
data = await Scraper.scrape(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
return data
|
| 28 |
+
except:
|
| 29 |
+
return {"title": "error", "URL": url, "Content": "none"}
|
| 30 |
|