summary refs log tree commit diff
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-09-09 01:41:01 +0300
committertzlil <tzlils@protonmail.com>2023-09-09 01:41:01 +0300
commit9be9245c2ee7f8819ec05db69f26f4be7d6d041e (patch)
tree8cae666826605e18fbb1d2c9c2b4c1fdab70fd40
parent848dd36a72e11a859b9dafbdfb26cece3568d011 (diff)
why i didnt use the api
-rw-r--r--fuck you.py41
1 files changed, 41 insertions, 0 deletions
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 ??????????????????????????