.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.crossref Namespace Reference

Functions

None request (str query, "OnlineParams" params)
EngineResults response ("SXNG_Response" resp)

Variables

dict about
list categories = ["science", "scientific publications"]
bool paging = True
str search_url = "https://api.crossref.org/works"

Detailed Description

Crossref_ is the sustainable source of community-owned scholarly metadata and
is relied upon by thousands of systems across the research ecosystem and the
globe.

.. _Crossref: https://www.crossref.org/documentation/retrieve-metadata/

Function Documentation

◆ request()

None searx.engines.crossref.request ( str query,
"OnlineParams" params )

Definition at line 39 of file crossref.py.

39def request(query: str, params: "OnlineParams") -> None:
40 args = {
41 "query": query,
42 "offset": 20 * (params["pageno"] - 1),
43 }
44 params["url"] = f"{search_url}?{urlencode(args)}"
45
46

◆ response()

EngineResults searx.engines.crossref.response ( "SXNG_Response" resp)

Definition at line 47 of file crossref.py.

47def response(resp: "SXNG_Response") -> EngineResults:
48 res = EngineResults()
49 json_data = resp.json()
50
51 def field(k: str) -> str:
52 return str(record.get(k, ""))
53
54 for record in json_data["message"]["items"]:
55
56 if record["type"] == "component":
57 # These seem to be files published along with papers. Not something
58 # you'd search for.
59 continue
60 title: str = ""
61 journal: str = ""
62
63 if record["type"] == "book-chapter":
64 title = record["container-title"][0]
65 if record["title"][0].lower().strip() != title.lower().strip():
66 title += f" ({record['title'][0]})"
67 else:
68 title = record["title"][0] if "title" in record else record.get("container-title", [None])[0]
69 journal = record.get("container-title", [None])[0] if "title" in record else ""
70
71 item = res.types.Paper(
72 title=title,
73 journal=journal,
74 content=field("abstract"),
75 doi=field("DOI"),
76 pages=field("page"),
77 publisher=field("publisher"),
78 tags=record.get("subject"),
79 type=field("type"),
80 url=field("URL"),
81 volume=field("volume"),
82 )
83 res.add(item)
84
85 if "resource" in record and "primary" in record["resource"] and "URL" in record["resource"]["primary"]:
86 item.url = record["resource"]["primary"]["URL"]
87
88 if "published" in record and "date-parts" in record["published"]:
89 item.publishedDate = datetime(*(record["published"]["date-parts"][0] + [1, 1][:3]))
90
91 item.authors = [a.get("given", "") + " " + a.get("family", "") for a in record.get("author", [])]
92 item.isbn = record.get("isbn") or [i["value"] for i in record.get("isbn-type", [])]
93
94 # All the links are not PDFs, even if the URL ends with ".pdf"
95 # item.pdf_url = record.get("link", [{"URL": None}])[0]["URL"]
96
97 return res

Variable Documentation

◆ about

dict searx.engines.crossref.about
Initial value:
1= {
2 "website": "https://www.crossref.org/",
3 "wikidata_id": "Q5188229",
4 "official_api_documentation": "https://api.crossref.org/swagger-ui/",
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 20 of file crossref.py.

◆ categories

list searx.engines.crossref.categories = ["science", "scientific publications"]

Definition at line 29 of file crossref.py.

◆ paging

bool searx.engines.crossref.paging = True

Definition at line 30 of file crossref.py.

◆ search_url

str searx.engines.crossref.search_url = "https://api.crossref.org/works"

Definition at line 31 of file crossref.py.