Spaces:
Sleeping
Sleeping
| 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 |