提取嵌入式pdf

问题描述 投票:-1回答:1

我注意到docplayer.net嵌入了很多pdf。示例:http://docplayer.net/72489212-Excellence-in-prevention-descriptions-of-the-prevention-programs-and-strategies-with-the-greatest-evidence-of-success.html

但是,使用自动化工作流程提取这些pdf(即下载它们)的过程如何工作?

python pdf scrapy
1个回答
0
投票

您可以在网络/ XHR选项卡下的浏览器开发人员工具中注意到正在请求实际文档。在你的特殊情况下,它是在URL http://docplayer.net/storage/75/72489212/72489212.pdf上。现在,您可以尝试查看页面源,看看是否可以某种方式推断此URL。似乎XPath //iframe[@id="player_frame"]/@src可能会有所帮助。我没有检查过其他页面,但我认为这样的东西可能有用(你的parse方法的一部分):

...
url_template = 'http://docplayer.net/storage/{0}/{1}/{1}.pdf'
ids = response.xpath('//iframe[@id="player_frame"]/@src').re(r'/docview/([^/]+)/([^/]+)/')
file_url = url_template.format(*ids)
yield scrapy.Request(file_url, callback=self.parse_pdf)
...
© www.soinside.com 2019 - 2024. All rights reserved.