【发布时间】:2023-03-12 19:10:01
【问题描述】:
python 用于解析在线 pdf 以备将来使用。我的代码如下。
from tika import parser
import requests
import io
url = 'https://www.whitehouse.gov/wp-content/uploads/2017/12/NSS-Final-12-18-2017-0905.pdf'
response = requests.get(url)
with io.BytesIO(response.content) as open_pdf_file:
pdfFile = parser.from_file(open_pdf_file)
print(pdfFile)
但是,它显示
AttributeError: '_io.BytesIO' 对象没有属性 'decode'
我以How can i read a PDF file from inline raw_bytes (not from file)?为例
在示例中,它使用的是 PyPDF2。但我需要使用 Tika,因为 Tika 的结果比 PyPDF2 更好。
感谢您的帮助
【问题讨论】:
标签: python apache-tika tika-server