Python patent_stil教程
前言
使用 Python 的 patent_stil 采集专利数据,patent_stil 是一个专门用于采集谷歌专利、FPO 专利的集成数据采集库,patent_stil 通过函数式的调用方式实现了专利数据的高效获取。
一、patent_stil 是什么?
patent_stil 是基于 Python 的一种工具包,该工具是为了解决专利数据采集而构建和开发的,由科创实验室组织的成员开发和维护,目前仅发布了 0.1.1 版本,支持基础专利数据的获取操作。
二、使用步骤
1. 安装库
pip install patent-stil -i https://pypi.org/simple
2. 使用谷歌专利接口获取专利数据
#导入专利采集库
import patent_stil
#获取指定专利号的所有数据
res=patent_stil.getGooglePatentInfo("CN111587459B",language="auto",proxies="clash")
print("专利标题:",res.title)
print("专利发明者:",res.inventors)
print("专利摘要:",res.abstract)
print("专利正文:",res.descriptions)
国内谷歌网站无法访问,可以使用镜像网址,通过设置 base_url 参数即可实现,该处使用专利号、申请号获取指定专利号数据。参数 1 为专利号,参数 2 为返回的语言类型,参数 3 为代理参数。运行结果如下所示:
![][img-0]
2. 获取专利 json 数据
import patent_stil as patent_stil
#获取指定谷歌专利页面详情数据的json格式
res=patent_stil.getGooglePatentInfoByUrl("https://patents.google.com/patent/CN111587459B/zh?")
print(res)
使用 getGooglePatentInfoByUrl() 方法传递一个谷歌专利页面的 url, 即可获取解析的 json 数据格式。
3. 下载专利 pdf 文件
import patent_stil as patent_stil
res=patent_stil.getGooglePatentInfo("CN111587459B",language="auto",proxies="clash")
print("专利pdf地址:",res.pdf_url)
#根据pdf_url下载对应的专利文件
patent_stil.downloadGooglePdf(res.pdf_url,save_path="./test.pdf")
使用 downloadGooglePdf() 方法可以下载对应的专利 pdf 文件到指定目录。
3. 自动爬取专利所有数据
import patent_stil as patent_stil
#自动爬取对应的专利数据到默认data目录,并且不爬取pdf文件
patent_stil.autoGoogleSpider("CN111587459B",save_pdf=False)
使用 autoGoogleSpider() 方法,通过传递指定的专利号下载专利数据到指定目录,默认是在程序运行目录创建一个 data 目录存放爬取的专利数据。运行结果如下所示:
总结
以上就是今天要讲的内容,本文仅仅简单介绍了 patent_stil 库的使用,后续 patent_stil 也会不断更新更多的功能。相关 BUG 请前往 gitee 进行反馈。[Issues · 科技创新实验室 / Python 专利采集库 - Gitee.comhttps://gitee.com/hbue_stil/patent_stil/issues](https://gitee.com/hbue_stil/patent_stil/issues "Issues · 科技创新实验室/Python专利采集库 - Gitee.com")
Metadata
Release files for patent-stil 0.2.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| patent_stil-0.2.12.tar.gz | 323.4 kB | Without provenance | Details for patent_stil-0.2.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patent_stil-0.2.12-py3-none-any.whl | Python 3 | none | any | Details for patent_stil-0.2.12-py3-none-any.whl |
Total release size: 493.7 kB
Release files / patent_stil-0.2.12.tar.gz
| Download URL | patent_stil-0.2.12.tar.gz |
|---|---|
| Size | 323.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d5833a9cb4b28a4eeedd44e1e63ab7df2c9551a2a6e7f575d7bc7bc1471c66d
|
|
BLAKE2b-256 checksum How to use checksums |
52d097e399c481af1c7b93ccdabbcdf006e047293df0009325bd56dfa9166f5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / patent_stil-0.2.12-py3-none-any.whl
| Download URL | patent_stil-0.2.12-py3-none-any.whl |
|---|---|
| Size | 170.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75462220768dc22c4eb8a19e76e0852e3ecafeef9cec5514f437ed1e92ebf4fc
|
|
BLAKE2b-256 checksum How to use checksums |
a9046ea3ba3ec1e06d8d159c36104e10cb7eecfc7510ae35cca81a81b5dc8825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for patent-stil 0.2.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.