From 9be9245c2ee7f8819ec05db69f26f4be7d6d041e Mon Sep 17 00:00:00 2001 From: tzlil Date: Sat, 9 Sep 2023 01:41:01 +0300 Subject: why i didnt use the api --- fuck you.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 fuck you.py (limited to 'fuck you.py') diff --git a/fuck you.py b/fuck you.py new file mode 100644 index 0000000..f75a220 --- /dev/null +++ b/fuck you.py @@ -0,0 +1,41 @@ +import requests as rq +from lxml import etree as ET +import logging + +category = 'quant-ph' +namespaces = {'opensearch':'http://a9.com/-/spec/opensearch/1.1/', 'atom':'http://www.w3.org/2005/Atom'} + +logging.basicConfig() +logging.getLogger().setLevel(logging.DEBUG) +requests_log = logging.getLogger("requests.packages.urllib3") +requests_log.setLevel(logging.DEBUG) +requests_log.propagate = True + +def find_real_amount(): + r = lambda offset: ET.fromstring(rq.get('http://export.arxiv.org/api/query', params={ + 'search_query': f'cat:{category}', + 'start': offset, + 'max_results': 1, + }).content) + + lo = 0 + hi = int(r(lo).xpath('//opensearch:totalResults', namespaces=namespaces)[0].text) + while lo < hi: + mid = (lo+hi)//2 + s = r(mid).xpath('//atom:entry', namespaces=namespaces) + if len(s) > 0: + lo = mid+1 + else: + hi = mid + return hi + + +r = rq.get('http://export.arxiv.org/api/query', params={ + 'search_query': f'cat:{category}', + 'max_results': '1', + 'start':'138582', +}) + +root = ET.fromstring(r.content) +totalResults = root.xpath('//opensearch:totalResults', namespaces={'opensearch':'http://a9.com/-/spec/opensearch/1.1/'}) +# WHY DOES THE API STOP GIVING ME RESULTS AFTER START=49999 ?????????????????????????? -- cgit 1.4.1