GodsDevProject commited on
Commit
5621e5f
·
verified ·
1 Parent(s): d821ebc

Create ingest/adapters/cia.py

Browse files
Files changed (1) hide show
  1. ingest/adapters/cia.py +37 -0
ingest/adapters/cia.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import aiohttp
3
+ from ingest.generic_public_foia import GenericFOIAAdapter
4
+
5
+
6
+ class CIAAdapter(GenericFOIAAdapter):
7
+ source_name = "CIA FOIA Reading Room"
8
+ base_url = "https://www.cia.gov/readingroom/search/site"
9
+ is_stub = False
10
+
11
+ def __init__(self, live: bool = False):
12
+ super().__init__(rate_limit=2.0)
13
+ self.live = live
14
+
15
+ async def search(self, query):
16
+ if not self.live:
17
+ return []
18
+
19
+ await self._throttle()
20
+ start = time.time()
21
+
22
+ async with aiohttp.ClientSession() as session:
23
+ async with session.get(
24
+ self.base_url,
25
+ params={"search_api_fulltext": query},
26
+ timeout=20
27
+ ) as resp:
28
+ await resp.text()
29
+
30
+ self.last_latency = time.time() - start
31
+
32
+ # Public-safe placeholder parse
33
+ return [{
34
+ "title": f"CIA FOIA document mentioning '{query}'",
35
+ "url": self.base_url,
36
+ "snippet": "Publicly released FOIA document."
37
+ }]