Skip to main content
 首页 » 编程设计

python之使用谷歌专利 API

2024年10月24日17虾米姐

我只是想使用 Python 和 Google 专利搜索 API 找出专利的所有者。

import urllib2 
import json 
 
url = ('https://ajax.googleapis.com/ajax/services/search/patent?' + 
       'v=1.0&q=barack%20obama') 
 
request = urllib2.Request(url, None, {}) 
response = urllib2.urlopen(request) 
 
# Process the JSON string. 
print json.load(response) 
# now have some fun with the results... 

这个结果并没有说明受让人。我怎样才能得到它?

请您参考如下方法:

Google 专利 API 已弃用(“The Google Patent Search API has been officially deprecated as of May 26, 2011.”)。我认为您获得的数据不可靠。

我不确定 Google 服务条款是否允许针对个别 Google 专利页面,但一种策略可能是使用搜索来获取结果列表,然后使用类似 Beautiful Soup 的内容。解析每个结果。

例子:

import urllib2 
import json 
from bs4 import BeautifulSoup 
 
url = ('https://ajax.googleapis.com/ajax/services/search/patent?' + 
       'v=1.0&q=barack%20obama') 
request = urllib2.Request(url, None, {}) 
response = urllib2.urlopen(request) 
jsonResponse = json.load(response) 
responseData=jsonResponse['responseData'] 
results = responseData["results"] 
 
print "This doesn't work, no assignee data..." 
for result in results: 
    print "patent no.: ", result["patentNumber"] 
    print "assignee: ", result["assignee"] 
    print " " 
 
print "...but this seems to." 
for result in results: 
    URL = "https://www.google.com/patents/"+result["patentNumber"] 
    req = urllib2.Request(URL, headers={'User-Agent' : "python"}) 
    _file = urllib2.urlopen(req) 
    patent_html = _file.read() 
    soup = BeautifulSoup(patent_html, 'html.parser') 
    patentNumber = soup.find("span", { "class" : "patent-number" }).text 
    assigneeMetaTag = soup.find("meta", { "scheme" : "assignee"}) 
    patentAssignee = assigneeMetaTag.attrs["content"] 
    print "patent no.: ", patentNumber 
    print "assignee: ", patentAssignee 
    print " " 

对我来说,这是打印出来的:

This doesn't work, no assignee data... 
patent no.:  US20110022394 
assignee: 
 
patent no.:  US20140089323 
assignee: 
 
patent no.:  US8117227 
assignee: 
 
patent no.:  CA2702937C 
assignee: 
 
...but this seems to. 
patent no.:  US 20110022394 A1 
assignee:  Thomas Wide 
 
patent no.:  US 20140089323 A1 
assignee:  Appinions Inc. 
 
patent no.:  US 8117227 B2 
assignee:  Scuola Normale Superiore Di Pisa 
 
patent no.:  CA 2702937 C 
assignee:  Neil S. Roseman 

请注意,我相信您只能在专利发布之日获得受让人;在已转移的情况下,不是当前的受让人。