petermr / dictionary

Collection of Wikidata-based dictionaries for scientific annotation and searching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need some advice

ayush4921 opened this issue · comments

I can use some advice on how flexible the api of pygetpapers should be and what should the structure of the code be like. Should i have subclasses for each repository and have different methods between those subclasses or should i have a class for the api and the methods as the different repos?
I can use any method comfortably but I can really benefit from the advice because one of the reasons of switching from the node version is to make the api more maintainable
class getpapersall:
def init(self, **kwargs):
import urllib.request as libreq
import feedparser
with libreq.urlopen(f'http://export.arxiv.org/api/query?search_query=all:{kwargs["query"]}&start=0&max_results={kwargs["number"]}') as url:
r = url.read()
feed = feedparser.parse(r)
for entry in feed.entries:
x = entry.link
a = ((x.split('/'))[-1]).split(".")
b = (a[-1].split('v'))[0]
c = f'https://arxiv.org/ftp/arxiv/papers/{a[0]}/{a[0]}.{b}.pdf'
print(c)
a = getpapersall(query="Artificial+Intelligence", number="10")
This currenltly doesnt work because I have not assigned it a task
but a modified version of this gives the authors of the papers. Now should i have the init method as a method named getauthors.
or should I have it as a parameter in the init of the main class itself