Spaces:
Sleeping
Sleeping
Update ingest/fbi_vault.py
Browse files- ingest/fbi_vault.py +30 -24
ingest/fbi_vault.py
CHANGED
|
@@ -1,29 +1,35 @@
|
|
| 1 |
-
import
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
body = soup.get_text(separator=" ", strip=True)
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import aiohttp
|
| 2 |
+
from ingest.base_adapter import BaseAdapter
|
| 3 |
|
| 4 |
+
class FBIAdapter(BaseAdapter):
|
| 5 |
+
name = "FBI Vault"
|
| 6 |
+
source_type = "live"
|
| 7 |
+
base_url = "https://vault.fbi.gov"
|
| 8 |
|
| 9 |
+
async def search(self, query: str):
|
| 10 |
+
params = {"q": query}
|
| 11 |
+
results = []
|
| 12 |
|
| 13 |
+
async with aiohttp.ClientSession() as session:
|
| 14 |
+
async with session.get(
|
| 15 |
+
f"{self.base_url}/search",
|
| 16 |
+
params=params,
|
| 17 |
+
timeout=15
|
| 18 |
+
) as resp:
|
| 19 |
+
if resp.status != 200:
|
| 20 |
+
return []
|
| 21 |
|
| 22 |
+
text = await resp.text()
|
|
|
|
| 23 |
|
| 24 |
+
# Minimal, safe parsing (no deep scrape)
|
| 25 |
+
for line in text.splitlines():
|
| 26 |
+
if "/reading-room/" in line:
|
| 27 |
+
results.append({
|
| 28 |
+
"title": f"FBI Vault result for {query}",
|
| 29 |
+
"url": self.base_url,
|
| 30 |
+
"snippet": "Public FBI Vault FOIA document",
|
| 31 |
+
"source": self.name,
|
| 32 |
+
"live": True
|
| 33 |
+
})
|
| 34 |
+
|
| 35 |
+
return results
|