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

Functions

 request (query, params)
 
 response (resp)
 

Variables

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

Detailed Description

CrossRef

Function Documentation

◆ request()

searx.engines.crossref.request ( query,
params )

Definition at line 21 of file crossref.py.

21def request(query, params):
22 params["url"] = search_url + "?" + urlencode({"query": query, "offset": 20 * (params["pageno"] - 1)})
23 return params
24
25

◆ response()

searx.engines.crossref.response ( resp)

Definition at line 26 of file crossref.py.

26def response(resp):
27 results = []
28 for record in resp.json()["message"]["items"]:
29
30 if record["type"] == "component":
31 # These seem to be files published along with papers. Not something you'd search for
32 continue
33 result = {
34 "template": "paper.html",
35 "content": record.get("abstract", ""),
36 "doi": record.get("DOI"),
37 "pages": record.get("page"),
38 "publisher": record.get("publisher"),
39 "tags": record.get("subject"),
40 "type": record.get("type"),
41 "url": record.get("URL"),
42 "volume": record.get("volume"),
43 }
44 if record["type"] == "book-chapter":
45 result["title"] = record["container-title"][0]
46 if record["title"][0].lower().strip() != result["title"].lower().strip():
47 result["title"] += f" ({record['title'][0]})"
48 else:
49 result["title"] = record["title"][0] if "title" in record else record.get("container-title", [None])[0]
50 result["journal"] = record.get("container-title", [None])[0] if "title" in record else None
51
52 if "resource" in record and "primary" in record["resource"] and "URL" in record["resource"]["primary"]:
53 result["url"] = record["resource"]["primary"]["URL"]
54 if "published" in record and "date-parts" in record["published"]:
55 result["publishedDate"] = datetime(*(record["published"]["date-parts"][0] + [1, 1][:3]))
56 result["authors"] = [a.get("given", "") + " " + a.get("family", "") for a in record.get("author", [])]
57 result["isbn"] = record.get("isbn") or [i["value"] for i in record.get("isbn-type", [])]
58 # All the links are not PDFs, even if the URL ends with ".pdf"
59 # result["pdf_url"] = record.get("link", [{"URL": None}])[0]["URL"]
60
61 results.append(result)
62
63 return results

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",
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 7 of file crossref.py.

◆ categories

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

Definition at line 16 of file crossref.py.

◆ paging

bool searx.engines.crossref.paging = True

Definition at line 17 of file crossref.py.

◆ search_url

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

Definition at line 18 of file crossref.py.