File size: 813 Bytes
ca895cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import aiohttp
from bs4 import BeautifulSoup
from ingest.generic_public_foia import GenericFOIAAdapter

class DOJAdapter(GenericFOIAAdapter):
    source_name = "DOJ"
    base_url = "https://www.justice.gov/oip/foia-library"

    async def search(self, query: str):
        if not self.robots_allowed():
            return []

        await self._rate_limit()

        async with aiohttp.ClientSession() as session:
            async with session.get(self.base_url) as resp:
                html = await resp.text()

        if query.lower() not in html.lower():
            return []

        return [{
            "source": self.source_name,
            "title": "DOJ FOIA Library Reference",
            "url": self.base_url,
            "snippet": f"Query '{query}' appears in DOJ FOIA Library page"
        }]