Commit 987e9831 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

download patent info from Google instead of EPO

EPO REST API v3.1 is deprecated (see http://www.epo.org/service-support/updates/2018/20180104.html)
This fixes #72


Former-commit-id: 574d12295d9bb6b82c9741d9094963f8a51151f9
parent 4c6998b1
......@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.db.models import Max
from .ws import get_pubmed_info, get_epo_info, get_uniprot_info, get_taxonomy_info, get_go_info, get_pfam_info
from .ws import get_pubmed_info, get_google_patent_info, get_uniprot_info, get_taxonomy_info, get_go_info, get_pfam_info
class AutoFillableModel(models.Model):
......@@ -56,7 +56,7 @@ class Bibliography(AutoFillableModel):
if self.source == 'PM':
info = get_pubmed_info(self.id_source)
else:
info = get_epo_info(self.id_source)
info = get_google_patent_info(self.id_source)
self.title = info['title']
self.journal_name = info['journal_name']
self.authors_list = info['authors_list']
......
......@@ -44,6 +44,24 @@ def get_epo_info(patent_number):
'biblio_year': biblio_year,
'authors_list': authors}
def get_google_patent_info(patent_number):
url = 'https://encrypted.google.com/patents/{}.ris'.format(patent_number)
resp = requests.get(url)
title = None
authors = []
biblio_year = None
for line_str in resp.text.split("\n"):
line = line_str.strip().split(" - ")
if line[0] == "A1":
authors.append(line[1])
elif line[0] == "T1":
title = line[1]
elif line[0] == "Y1":
biblio_year = line[1].split("/")[0]
return {'title': title,
'journal_name': None,
'biblio_year': biblio_year,
'authors_list': authors}
def get_uniprot_info(uniprot_id):
uniprot_client = UniProt()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment