Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import json
|
|
| 5 |
|
| 6 |
def wayback(website):
|
| 7 |
if not website:
|
| 8 |
-
return '
|
| 9 |
|
| 10 |
# Intenta primero con la Wayback CDX Server API
|
| 11 |
end_date = datetime.now()
|
|
@@ -19,15 +19,14 @@ def wayback(website):
|
|
| 19 |
if response.status_code == 200:
|
| 20 |
content = json.loads(response.text)
|
| 21 |
if len(content) > 1:
|
| 22 |
-
results = []
|
| 23 |
for row in content[1:]:
|
| 24 |
date, page, status = [row[i] for i in [1, 2, 4]]
|
| 25 |
formatted_date = datetime.strptime(date, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
|
| 26 |
formatted_wayback_url = f"https://web.archive.org/web/{date}/{page}"
|
| 27 |
-
results.append({
|
| 28 |
-
results.
|
| 29 |
-
|
| 30 |
-
return "<br>".join(formatted_results)
|
| 31 |
except Exception as e:
|
| 32 |
pass # Falla silenciosa, intentar con el siguiente método
|
| 33 |
|
|
@@ -43,7 +42,7 @@ def wayback(website):
|
|
| 43 |
snapshot_url = closest_snapshot["url"]
|
| 44 |
timestamp = closest_snapshot["timestamp"]
|
| 45 |
formatted_date = datetime.strptime(timestamp, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
|
| 46 |
-
return f"
|
| 47 |
except Exception as e:
|
| 48 |
return f"<p>😭 Error: {e}</p>"
|
| 49 |
|
|
|
|
| 5 |
|
| 6 |
def wayback(website):
|
| 7 |
if not website:
|
| 8 |
+
return '<p>😭 Error: introduce una url correcta</p>'
|
| 9 |
|
| 10 |
# Intenta primero con la Wayback CDX Server API
|
| 11 |
end_date = datetime.now()
|
|
|
|
| 19 |
if response.status_code == 200:
|
| 20 |
content = json.loads(response.text)
|
| 21 |
if len(content) > 1:
|
| 22 |
+
results = ["<table><tr><th>Fecha</th><th>URL</th></tr>"]
|
| 23 |
for row in content[1:]:
|
| 24 |
date, page, status = [row[i] for i in [1, 2, 4]]
|
| 25 |
formatted_date = datetime.strptime(date, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
|
| 26 |
formatted_wayback_url = f"https://web.archive.org/web/{date}/{page}"
|
| 27 |
+
results.append(f"<tr><td>{formatted_date}</td><td><a href='{formatted_wayback_url}' target='_blank'>{formatted_wayback_url}</a></td></tr>")
|
| 28 |
+
results.append("</table>")
|
| 29 |
+
return "".join(results)
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
pass # Falla silenciosa, intentar con el siguiente método
|
| 32 |
|
|
|
|
| 42 |
snapshot_url = closest_snapshot["url"]
|
| 43 |
timestamp = closest_snapshot["timestamp"]
|
| 44 |
formatted_date = datetime.strptime(timestamp, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
|
| 45 |
+
return f"<table><tr><th>Fecha</th><th>URL</th></tr><tr><td>{formatted_date}</td><td><a href='{snapshot_url}' target='_blank'>{snapshot_url}</a></td></tr></table>"
|
| 46 |
except Exception as e:
|
| 47 |
return f"<p>😭 Error: {e}</p>"
|
| 48 |
|