Skip to content

Commit

Permalink
familly gatherer update. epo-ops client provide error on some case. B…
Browse files Browse the repository at this point in the history
…ypass the use of the client.
  • Loading branch information
Patent2net committed Sep 30, 2022
1 parent d173fdb commit c56535f
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions Patent2Net/P2N_Lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2769,10 +2769,35 @@ def GetFamilly(client, brev, rep):
cpt = 1
except:
# IF WE ARE HERE? i SUPPOSE THAT EQUIVALENTS PATENTS SHOULD BE CHECKED

print("nothing found for ", brev)
print("ignoring")
return None
# found error on ops client... try to bypass by direct access
import requests
from requests.structures import CaseInsensitiveDict
url = "http://ops.epo.org/3.2/rest-services/family/publication/docdb/" + label
headers = CaseInsensitiveDict()
# headers["Accept"] = "application/json"
headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"
if not client.access_token.is_expired:
headers["Authorization"] = "Bearer " + client.access_token.token #
else:
client = epo_ops.Client(key, secret)
client.accept_type = 'application/json'
headers["Authorization"] = "Bearer " + client.access_token.token
headers['Content-Type'] = 'text/plain;charset=utf-8'
try:
data = requests.get(url, headers=headers)
except:
url = "http://ops.epo.org/3.2/rest-services/family/publication/epodoc/" + label
try:
data = requests.get(url, headers=headers)
except:
print("Not Found ", label)
dico = None
try:
data = data.json()
except:
data = xmltodict.parse(data.text)
dico = data['ops:world-patent-data']['ops:patent-family']['ops:family-member']


if dico is not None:

Expand Down

0 comments on commit c56535f

Please sign in to comment.