1

我正在尝试使用本地机器中内置的 Grobid,但此脚本打印 500 错误。而当我使用 Curl 从 CLI 执行此操作时,它工作正常。请帮忙!

    import requests

    url = 'http://localhost:8080/processHeaderDocument'
    files={'file': open('file.pdf', 'rb')}
    r = requests.post(url,files=files)
    print r.status_code
4

1 回答 1

2

这对我行得通:

import requests

url = 'http://localhost:8080/api/processHeaderDocument'
multipart_form_data = {
    'input': open('file.pdf', 'rb')
}
r = requests.post(url, files=multipart_form_data)

assert response.status_code == 200, response.content
print(response.content)


# extracting xml
from lxml import objectify
root = objectify.fromstring(response.content)
title = root.teiHeader.fileDesc.titleStmt.title
于 2018-02-05T15:24:13.180 回答