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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['science', 'scientific publications']
 
bool paging = True
 
tuple base_url
 
int number_of_results = 10
 
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 (Scientific preprints)

Function Documentation

◆ request()

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

Definition at line 50 of file arxiv.py.

50def request(query, params):
51 # basic search
52 offset = (params['pageno'] - 1) * number_of_results
53
54 string_args = {'query': query, 'offset': offset, 'number_of_results': number_of_results}
55
56 params['url'] = base_url.format(**string_args)
57
58 return params
59
60

◆ response()

searx.engines.arxiv.response ( resp)

Definition at line 61 of file arxiv.py.

61def response(resp):
62 results = []
63 dom = etree.fromstring(resp.content)
64 for entry in eval_xpath_list(dom, xpath_entry):
65 title = eval_xpath_getindex(entry, xpath_title, 0).text
66
67 url = eval_xpath_getindex(entry, xpath_id, 0).text
68 abstract = eval_xpath_getindex(entry, xpath_summary, 0).text
69
70 authors = [author.text for author in eval_xpath_list(entry, xpath_author_name)]
71
72 # doi
73 doi_element = eval_xpath_getindex(entry, xpath_doi, 0, default=None)
74 doi = None if doi_element is None else doi_element.text
75
76 # pdf
77 pdf_element = eval_xpath_getindex(entry, xpath_pdf, 0, default=None)
78 pdf_url = None if pdf_element is None else pdf_element.attrib.get('href')
79
80 # journal
81 journal_element = eval_xpath_getindex(entry, xpath_journal, 0, default=None)
82 journal = None if journal_element is None else journal_element.text
83
84 # tags
85 tag_elements = eval_xpath(entry, xpath_category)
86 tags = [str(tag) for tag in tag_elements]
87
88 # comments
89 comments_elements = eval_xpath_getindex(entry, xpath_comment, 0, default=None)
90 comments = None if comments_elements is None else comments_elements.text
91
92 publishedDate = datetime.strptime(eval_xpath_getindex(entry, xpath_published, 0).text, '%Y-%m-%dT%H:%M:%SZ')
93
94 res_dict = {
95 'template': 'paper.html',
96 'url': url,
97 'title': title,
98 'publishedDate': publishedDate,
99 'content': abstract,
100 'doi': doi,
101 'authors': authors,
102 'journal': journal,
103 'tags': tags,
104 'comments': comments,
105 'pdf_url': pdf_url,
106 }
107
108 results.append(res_dict)
109
110 return results

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://arxiv.org/help/api',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'XML-RSS',
8}

Definition at line 13 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 33 of file arxiv.py.

◆ base_url

tuple searx.engines.arxiv.base_url
Initial value:
1= (
2 'https://export.arxiv.org/api/query?search_query=all:' + '{query}&start={offset}&max_results={number_of_results}'
3)

Definition at line 25 of file arxiv.py.

◆ categories

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

Definition at line 22 of file arxiv.py.

◆ number_of_results

int searx.engines.arxiv.number_of_results = 10

Definition at line 30 of file arxiv.py.

◆ paging

bool searx.engines.arxiv.paging = True

Definition at line 23 of file arxiv.py.

◆ xpath_author_name

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

Definition at line 41 of file arxiv.py.

◆ xpath_category

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

Definition at line 46 of file arxiv.py.

◆ xpath_comment

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

Definition at line 47 of file arxiv.py.

◆ xpath_doi

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

Definition at line 42 of file arxiv.py.

◆ xpath_entry

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

Definition at line 37 of file arxiv.py.

◆ xpath_id

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

Definition at line 39 of file arxiv.py.

◆ xpath_journal

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

Definition at line 45 of file arxiv.py.

◆ xpath_pdf

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

Definition at line 43 of file arxiv.py.

◆ xpath_published

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

Definition at line 44 of file arxiv.py.

◆ xpath_summary

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

Definition at line 40 of file arxiv.py.

◆ xpath_title

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

Definition at line 38 of file arxiv.py.