wget 和 PDFFileReader - 无法读取格式错误的 PDF 文件

wget and PDFFileReader - Could not read malformed PDF file

我正在尝试从希腊卫生部的每日报告中抓取 COVID-19 数据,这些报告以 PDF 格式在线发布。我正在使用 wget 下载它们,然后使用 PyPDF2 来抓取它们以获取数据:

import wget
import PyPDF2

wget.download('https://eody.gov.gr/wp-content/uploads/2020/09/covid-gr-daily-report-23-09-2020.pdf')
reader = PyPDF2.PdfFileReader('covid-gr-daily-report-23-09-2020.pdf')

但是returns出现以下错误:

PyPDF2.utils.PdfReadError: Could not read malformed PDF file

目录中保存的PDF也打不开。

如何保存 PDF 以使其不变形?

您尝试下载的内容受 Google reCAPTCHA 保护。如果您查看响应文本,您应该会看到:

import requests

r = requests.get('https://eody.gov.gr/wp-content/uploads/2020/09/covid-gr-daily-report-23-09-2020.pdf')

print(r.text)

这是回复。你需要首先克服我不是机器人安全的事实:

<html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3">
</script>
<body>
</body></html>