mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-18 07:42:09 +00:00
aa
This commit is contained in:
@@ -2015,7 +2015,7 @@ async def wyszukaj_linki_do_dokumentow(ctx):
|
|||||||
for item in query_response.json():
|
for item in query_response.json():
|
||||||
logger.info(item)
|
logger.info(item)
|
||||||
resulttab.append(item["title"])
|
resulttab.append(item["title"])
|
||||||
item_link = "https://scihub.se/" + str(item["DOI"])
|
item_link = "https://sci-hub.se/" + str(item["DOI"])
|
||||||
resultlink.append(item_link)
|
resultlink.append(item_link)
|
||||||
for i in range(1,5):
|
for i in range(1,5):
|
||||||
query = quote_plus(resulttab[i-1])
|
query = quote_plus(resulttab[i-1])
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Librarian(object):
|
|||||||
netrc_mod = netrc.netrc(NETRC_FILE)
|
netrc_mod = netrc.netrc(NETRC_FILE)
|
||||||
authTokens = netrc_mod.authenticators("crossref")
|
authTokens = netrc_mod.authenticators("crossref")
|
||||||
self.cr = Crossref(mailto=authTokens[0])
|
self.cr = Crossref(mailto=authTokens[0])
|
||||||
self.limit = 200
|
self.limit = 20
|
||||||
|
|
||||||
def search_crossref(self, query, uuid):
|
def search_crossref(self, query, uuid):
|
||||||
search_result_from_cr = self.cr.works(query = query, limit = self.limit)
|
search_result_from_cr = self.cr.works(query = query, limit = self.limit)
|
||||||
@@ -68,7 +68,6 @@ class Librarian(object):
|
|||||||
# trunk-ignore(bandit/B310)
|
# trunk-ignore(bandit/B310)
|
||||||
with urlopen(page_url) as response:
|
with urlopen(page_url) as response:
|
||||||
info = response.info()
|
info = response.info()
|
||||||
print(info.get_content_type())
|
|
||||||
data = response.read()
|
data = response.read()
|
||||||
text = data.decode("utf-8")
|
text = data.decode("utf-8")
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
@@ -89,11 +88,13 @@ class Librarian(object):
|
|||||||
if self.check_if_exists(page_url):
|
if self.check_if_exists(page_url):
|
||||||
return page_url
|
return page_url
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def refine_query(self, unrefined_reqult):
|
def refine_query(self, unrefined_reqult):
|
||||||
|
print("Refine result")
|
||||||
refined_result = []
|
refined_result = []
|
||||||
for item in unrefined_reqult["summary"]:
|
for item in unrefined_reqult["summary"]:
|
||||||
if item["container"] == "NO":
|
if item["container"] == "NO":
|
||||||
item_link = "https://scihub.se/" + str(item['DOI'])
|
item_link = "https://sci-hub.se/" + str(item['DOI'])
|
||||||
if self.check_if_exists(item_link):
|
if self.check_if_exists(item_link):
|
||||||
refined_result.append(item)
|
refined_result.append(item)
|
||||||
print (item_link)
|
print (item_link)
|
||||||
@@ -103,6 +104,7 @@ class Librarian(object):
|
|||||||
def answer_query(self, query, uuid):
|
def answer_query(self, query, uuid):
|
||||||
#Search sql for UUID
|
#Search sql for UUID
|
||||||
#SQL SELECT * FROM RESULTS WHERE UUID = uuid
|
#SQL SELECT * FROM RESULTS WHERE UUID = uuid
|
||||||
|
print("Answer result")
|
||||||
uuid_found = False
|
uuid_found = False
|
||||||
database = None
|
database = None
|
||||||
with open("results.json", "r", encoding="UTF-8") as new_file:
|
with open("results.json", "r", encoding="UTF-8") as new_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user