GodsDevProject commited on
Commit
ca895cc
·
verified ·
1 Parent(s): dd04378

Create ingest/adapters/doj.py

Browse files
Files changed (1) hide show
  1. ingest/adapters/doj.py +27 -0
ingest/adapters/doj.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import aiohttp
2
+ from bs4 import BeautifulSoup
3
+ from ingest.generic_public_foia import GenericFOIAAdapter
4
+
5
+ class DOJAdapter(GenericFOIAAdapter):
6
+ source_name = "DOJ"
7
+ base_url = "https://www.justice.gov/oip/foia-library"
8
+
9
+ async def search(self, query: str):
10
+ if not self.robots_allowed():
11
+ return []
12
+
13
+ await self._rate_limit()
14
+
15
+ async with aiohttp.ClientSession() as session:
16
+ async with session.get(self.base_url) as resp:
17
+ html = await resp.text()
18
+
19
+ if query.lower() not in html.lower():
20
+ return []
21
+
22
+ return [{
23
+ "source": self.source_name,
24
+ "title": "DOJ FOIA Library Reference",
25
+ "url": self.base_url,
26
+ "snippet": f"Query '{query}' appears in DOJ FOIA Library page"
27
+ }]