Spaces:
Sleeping
Sleeping
File size: 604 Bytes
bb0b469 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from .common import fetch, clean
from bs4 import BeautifulSoup
def search_cia(query):
url = "https://www.cia.gov/readingroom/search/site/"
html = fetch(url, {"search_api_fulltext": query})
soup = BeautifulSoup(html, "html.parser")
results = []
for item in soup.select(".views-row"):
a = item.select_one("a")
if not a:
continue
results.append({
"title": clean(a.text),
"agency": "CIA",
"date": None,
"snippet": None,
"url": "https://www.cia.gov" + a["href"]
})
return results |