def cite_it(bot, chat_id, doi): """Returns citation for given DOI""" # headers = {"content-type":"application/x-bibtex"} # resp = requests.get("https://doi.org/" + DOI, headers=headers) # return resp.content works = Works() if not works.agency(doi): bot.send_message( chat_id=chat_id, text="Этот документ не входит в базу цитирования CrossRef...") return SEARCH_RESULTLS else: record = works.doi(doi) found, meta_bib = get_bib(doi) if not found: bot.send_message(chat_id=chat_id, text="Документ не найден...") return SEARCH_RESULTLS bot.send_message(chat_id=chat_id, text="Цитирование по CrossRef:") filename = doi.replace('/', '-') with open(os.path.join('downloads', filename + '.bib'), 'w+') as downloaded_file: downloaded_file.write(meta_bib) bot.send_document( chat_id=chat_id, document=open(os.path.join('downloads', filename + '.bib'), 'rb'), ) return SEARCH_RESULTLS
#!/usr/bin/python3 from crossref.restful import Works works = Works() output = works.agency('10.1590/0102-311x00133115') print(output)