.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.arxiv 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
int arxiv_max_results = 10
str arxiv_search_prefix = "all"
str base_url = "https://export.arxiv.org/api/query"
dict arxiv_namespaces
 xpath_entry = XPath("//atom:entry", namespaces=arxiv_namespaces)
 xpath_title = XPath(".//atom:title", namespaces=arxiv_namespaces)
 xpath_id = XPath(".//atom:id", namespaces=arxiv_namespaces)
 xpath_summary = XPath(".//atom:summary", namespaces=arxiv_namespaces)
 xpath_author_name = XPath(".//atom:author/atom:name", namespaces=arxiv_namespaces)
 xpath_doi = XPath(".//arxiv:doi", namespaces=arxiv_namespaces)
 xpath_pdf = XPath(".//atom:link[@title='pdf']", namespaces=arxiv_namespaces)
 xpath_published = XPath(".//atom:published", namespaces=arxiv_namespaces)
 xpath_journal = XPath(".//arxiv:journal_ref", namespaces=arxiv_namespaces)
 xpath_category = XPath(".//atom:category/@term", namespaces=arxiv_namespaces)
 xpath_comment = XPath("./arxiv:comment", namespaces=arxiv_namespaces)

Detailed Description

arXiv is a free distribution service and an open-access archive for nearly
2.4 million scholarly articles in the fields of physics, mathematics, computer
science, quantitative biology, quantitative finance, statistics, electrical
engineering and systems science, and economics.

The engine uses the `arXiv API`_.

.. _arXiv API: https://info.arxiv.org/help/api/user-manual.html

Function Documentation

◆ request()

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

Definition at line 68 of file arxiv.py.

68def request(query: str, params: "OnlineParams") -> None:
69
70 args = {
71 "search_query": f"{arxiv_search_prefix}:{query}",
72 "start": (params["pageno"] - 1) * arxiv_max_results,
73 "max_results": arxiv_max_results,
74 }
75 params["url"] = f"{base_url}?{urlencode(args)}"
76
77

◆ response()

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

Definition at line 78 of file arxiv.py.

78def response(resp: "SXNG_Response") -> EngineResults:
79
80 res = EngineResults()
81
82 dom = etree.fromstring(resp.content)
83 for entry in eval_xpath_list(dom, xpath_entry):
84
85 title: str = eval_xpath_getindex(entry, xpath_title, 0).text
86
87 url: str = eval_xpath_getindex(entry, xpath_id, 0).text
88 abstract: str = eval_xpath_getindex(entry, xpath_summary, 0).text
89
90 authors: list[str] = [author.text for author in eval_xpath_list(entry, xpath_author_name)]
91
92 # doi
93 doi_element = eval_xpath_getindex(entry, xpath_doi, 0, default=None)
94 doi: str = "" if doi_element is None else doi_element.text
95
96 # pdf
97 pdf_element = eval_xpath_getindex(entry, xpath_pdf, 0, default=None)
98 pdf_url: str = "" if pdf_element is None else pdf_element.attrib.get("href")
99
100 # journal
101 journal_element = eval_xpath_getindex(entry, xpath_journal, 0, default=None)
102 journal: str = "" if journal_element is None else journal_element.text
103
104 # tags
105 tag_elements = eval_xpath(entry, xpath_category)
106 tags: list[str] = [str(tag) for tag in tag_elements]
107
108 # comments
109 comments_elements = eval_xpath_getindex(entry, xpath_comment, 0, default=None)
110 comments: str = "" if comments_elements is None else comments_elements.text
111
112 publishedDate = datetime.strptime(eval_xpath_getindex(entry, xpath_published, 0).text, "%Y-%m-%dT%H:%M:%SZ")
113
114 res.add(
115 res.types.Paper(
116 url=url,
117 title=title,
118 publishedDate=publishedDate,
119 content=abstract,
120 doi=doi,
121 authors=authors,
122 journal=journal,
123 tags=tags,
124 comments=comments,
125 pdf_url=pdf_url,
126 )
127 )
128
129 return res

Variable Documentation

◆ about

dict searx.engines.arxiv.about
Initial value:
1= {
2 "website": "https://arxiv.org",
3 "wikidata_id": "Q118398",
4 "official_api_documentation": "https://info.arxiv.org/help/api/user-manual.html",
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": "XML-RSS",
8}

Definition at line 26 of file arxiv.py.

◆ arxiv_max_results

int searx.engines.arxiv.arxiv_max_results = 10

Definition at line 37 of file arxiv.py.

◆ arxiv_namespaces

dict searx.engines.arxiv.arxiv_namespaces
Initial value:
1= {
2 "atom": "http://www.w3.org/2005/Atom",
3 "arxiv": "http://arxiv.org/schemas/atom",
4}

Definition at line 51 of file arxiv.py.

◆ arxiv_search_prefix

str searx.engines.arxiv.arxiv_search_prefix = "all"

Definition at line 38 of file arxiv.py.

◆ base_url

str searx.engines.arxiv.base_url = "https://export.arxiv.org/api/query"

Definition at line 45 of file arxiv.py.

◆ categories

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

Definition at line 35 of file arxiv.py.

◆ paging

bool searx.engines.arxiv.paging = True

Definition at line 36 of file arxiv.py.

◆ xpath_author_name

searx.engines.arxiv.xpath_author_name = XPath(".//atom:author/atom:name", namespaces=arxiv_namespaces)

Definition at line 59 of file arxiv.py.

◆ xpath_category

searx.engines.arxiv.xpath_category = XPath(".//atom:category/@term", namespaces=arxiv_namespaces)

Definition at line 64 of file arxiv.py.

◆ xpath_comment

searx.engines.arxiv.xpath_comment = XPath("./arxiv:comment", namespaces=arxiv_namespaces)

Definition at line 65 of file arxiv.py.

◆ xpath_doi

searx.engines.arxiv.xpath_doi = XPath(".//arxiv:doi", namespaces=arxiv_namespaces)

Definition at line 60 of file arxiv.py.

◆ xpath_entry

searx.engines.arxiv.xpath_entry = XPath("//atom:entry", namespaces=arxiv_namespaces)

Definition at line 55 of file arxiv.py.

◆ xpath_id

searx.engines.arxiv.xpath_id = XPath(".//atom:id", namespaces=arxiv_namespaces)

Definition at line 57 of file arxiv.py.

◆ xpath_journal

searx.engines.arxiv.xpath_journal = XPath(".//arxiv:journal_ref", namespaces=arxiv_namespaces)

Definition at line 63 of file arxiv.py.

◆ xpath_pdf

searx.engines.arxiv.xpath_pdf = XPath(".//atom:link[@title='pdf']", namespaces=arxiv_namespaces)

Definition at line 61 of file arxiv.py.

◆ xpath_published

searx.engines.arxiv.xpath_published = XPath(".//atom:published", namespaces=arxiv_namespaces)

Definition at line 62 of file arxiv.py.

◆ xpath_summary

searx.engines.arxiv.xpath_summary = XPath(".//atom:summary", namespaces=arxiv_namespaces)

Definition at line 58 of file arxiv.py.

◆ xpath_title

searx.engines.arxiv.xpath_title = XPath(".//atom:title", namespaces=arxiv_namespaces)

Definition at line 56 of file arxiv.py.