Spaces:
Sleeping
Sleeping
| import aiohttp | |
| from ingest.generic_public_foia import GenericFOIAAdapter | |
| class FBIAdapter(GenericFOIAAdapter): | |
| source_name = "FBI Vault" | |
| base_url = "https://vault.fbi.gov" | |
| source_type = "live" | |
| async def search(self, query: str): | |
| await self._rate_limit() | |
| try: | |
| async with aiohttp.ClientSession() as session: | |
| async with session.get( | |
| f"{self.base_url}/search", | |
| params={"q": query}, | |
| timeout=12 | |
| ) as resp: | |
| if resp.status != 200: | |
| return [] | |
| text = await resp.text() | |
| if "reading-room" in text.lower(): | |
| return [{ | |
| "source": self.source_name, | |
| "title": f"FBI Vault document mentioning '{query}'", | |
| "url": f"{self.base_url}/search?q={query}", | |
| "snippet": "Public FBI FOIA document from The Vault.", | |
| "live": True, | |
| "extended": False | |
| }] | |
| except Exception: | |
| return [] | |
| return [] |