问题标签 [pdf-scraping]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1898 浏览

pdf-scraping - 使用 camelot 从 PDF 中提取表格数据时,没有从 PDF 中提取标题

我正在使用 camelot 进行表数据提取,但是标题没有被提取为 PDF 的一部分。

下面附上目标PDF链接和目标表在第3页和第4页,需要提取。

https://drive.google.com/file/d/1xniTIwpnNIdA_k4xvEARlVH97Lk-K2Yr/view?usp=sharing

其中一张表如下所示 在此处输入图像描述

我看过 camelot 文档,我认为问题与“检测短线”有关

https://camelot-py.readthedocs.io/en/master/user/advanced.html#detect-short-lines

但是无法通过调整line_size_scaling参数来解决问题。

请协助。

0 投票
1 回答
125 浏览

r - 尝试在 R 中抓取 PDF,我的代码只会抓取 9 页中的 6 页,我不知道为什么,我的代码中是否遗漏了什么?

我试图在 R 中抓取几个 PDF,PDF1 有 9 页,PDF2 有 12 页。当我运行下面的代码时,它会刮掉两个 PDF,但只能刮到第 6 页,之后什么也没有。是否有一个原因?我的代码中缺少什么?

您可以在以下网址找到 PDF:https ://www.scribd.com/document/396797318/123

0 投票
1 回答
655 浏览

python - 如何在我的 pdfminer 代码中使用正则表达式来提取两个标题之间的文本?

我有几个要从中提取数据的 PDF。我已经设法使用下面的代码从 PDF 中提取所有数据,但是现在我想在两个不同的标题之间提取文本。我相信使用正则表达式是最好的方法,因为两个标题之间的文本会有所不同,但每个 PDF 的两个标题将保持不变。

这是一个示例 PDF:https ://www.scribd.com/document/396797318/123

我想提取标题“3.​​ Induction Training”和“4. Corporate Training/Departmental Training”之间的所有文本

以下代码是我用来从 PDF 中提取数据的代码:

我可以使用什么正则表达式来获取我需要的信息?

0 投票
1 回答
826 浏览

python - 使用 Textract 提取/抓取 PDF - 不打印文本

我正在尝试使用 Textract 提取 doem PDF 文件中的文本。但是,当我在代码末尾打印文本时,它只会打印出很多空格。谁能指出我正在发生的事情的方向?(顺便说一句,文本不是=“”)

0 投票
1 回答
243 浏览

python - 使用 pypdf2 抓取单页 pdf 时不返回文本

我已经从这个来源下载了一堆 pdf:' http://ec.europa.eu/growth/tools-databases/cosing/index.cfm?fuseaction=search.detailsPDF_v2&id=28157

现在我想使用 PyPDF2 来抓取 PDF,但是没有返回任何文本。

我用另一个pdf测试了代码,它没有问题。

0 投票
2 回答
1429 浏览

r - R中的Tabulizer包:如何在特定标题后抓取表格

如何从PDF中刮取带有一些标题文本的表格?我正在尝试使用 tabulizer 包。这是从特定页面获取表格的示例(波兰语“公共卫生需求地图”)

这让我在特定页面获得一张桌子。但是我会从网站上刮掉很多这样的 pdf:http : //www.mpz.mz.gov.pl/mapy-dla-30-grup-chorob-2018/,然后是每个疾病都有很多链接的子页面,获取与 rvest 的链接,对于波兰的每个省,我需要在特定的标题字符串之后抓取表格,例如。

Tabela 1.2.2: Struktura zapadalnosci rejestrowanej w zależności od płci, miejsca zamieszkania oraz grupy wiekowej - Choroby układowe tkanki łącznej"

我需要检测 Tabela(...) Struktura zapadalnosci(...)",因为这些表格可能不在同一页面上。非常感谢您提前提供的任何指示和想法。

编辑:在我问了这个问题之后,到目前为止我成功地找到了表格可能所在的页面,可能非常无效:

0 投票
2 回答
1859 浏览

python - Title Extraction/Identification from PDFs

I have a large number of pdfs in different formats. Among other things, I need to extract their titles (not the document name, but a title in the text). Due to the range of formats, the titles are not in the same locations in the pdfs. Further, some of the pdfs are actually scanned images (I need to use OCR/Optical Character Recognition on them). The titles are sometimes one line, sometimes 2. They do not tend to have the same set of words. In the range of physical locations the titles usually show up, there are often other words (ie if doc 1 has title 1 at x1, y1, doc 2 might have title 2 at x2, y2 but have other non-title text at x1 y1). Further, there are some very rare cases where the pdfs don't have a title.

So far I can use pdftotext to extract text within a given bounding box, and convert it to a text file. If there's a title, this lets me capture the title, but often with other extraneous words included. This also only works on non-image pdfs. I'm wondering if a) There's a good way to identify the title from among all the words I extract for a document (because there are often extraneous words), ideally with a good way to identify that no title exists, and b) if there are any tools that are equivalent to pdftotext that will also work on scanned images (I do have an ocr script working, but it does ocr over an entire image rather than a section of one).

One method that somewhat answers the title dilemma is to extract the words in the bounding box, use the rest of the document to identify which of the bounding box words are keywords for the document, and construct the title from the keywords. This wouldn't extract the actual title, but may give words that could construct a reasonable alternative. I'm already extracting keywords for other parts of the project, but I would definitely prefer to extract the actual title as people may be using the verbatim title for lookup purposes.

Further note if it wasn't clear - I'm trying to do this programatically with open source/free tools, ideally in Python, and I will have a large number of documents (10,000+).

0 投票
1 回答
868 浏览

python - 清理从扫描的 .pdf 中提取的文本数据

我正在创建一个脚本来从扫描的 pdf 中提取文本,以创建一个 JSON 字典,以便稍后在 MongoDB 中实现。我遇到的问题是,通过 Textract 模块使用 tesseract-ocr 成功提取了所有文本,但它正在被 python 读取,因此 PDF 上的所有空白都被转换为 '\n' ,因此很难提取必要的信息。

我试过用一堆代码来清理它,但它仍然不是很可读。它去掉了所有的冒号,我觉得这将使识别键和值变得容易得多。

我仍然留下了相当多的不干净的几乎过度处理的数据。所以在这一点上,我知道如何使用它。

这就是我提取数据的方式

我也尝试过 nltk 并且取出了一些数据并使其更易于阅读,但是仍然有很多 \n 混淆了数据。

这是nltk代码:

这是我从我尝试的第一次清理中得到的:

我需要一个看起来像这样的 JSON 数组:

等等......我只是不知道该怎么做。我还可以提供原始输出。这是我触摸它之前的样子。以上数据是我制作完整数组所需的所有信息。

0 投票
0 回答
59 浏览

r - pdftools - Helvetica (?) 字体扭曲文本导入

我正在努力正确阅读包含 Helvetica 字体的 pdf pdftools

我正在尝试从大约 1000 条投票记录中提取信息。总体而言,pdftools按预期工作。但是,有一两百个 pdf 文件无法正确读取提取的文本。取而代之的是部分文本,例如第一行(= 标题),由一些“任意”字符组成。

据我所知,工作和不工作的唯一区别是 a) 字体(那些不工作的包含 Helvetica)和 b) pdf 的创建方式。似乎那些可以正常工作的 pdf 是在 Excle 中创建的,而那些不能正常工作的 pdf 是使用“Microsoft Reporting Service PDF Rendering Extension 10.0.0.0”创建的。

下面是我的代表,它给出了成功和不成功的导入示例。

我知道 Helvetica 经常会导致问题,因为它通常不会安装在 Windows 机器上。不过,据我所知,我的机器上有 Helvetica(虽然我并不真正理解pdf_font命令的结果;为什么嵌入了“假”)。

非常感谢!

从三个文档中获取字体。那些未正确导入的包含 Helvetica。

从三个文档中获取文本。注意第一个字符的区别。

会话信息:

0 投票
1 回答
94 浏览

r - 如何阅读 PDF 直到某一行?

我正在为许多研究论文做循环。在这里,我想从阅读文档中提取内容。

我怎样才能使 R 只读取到最后一行,那里有很多点,并指示为结束行?如下图所示:

[数字] [字母][点][数字]

在此处输入图像描述

如果没有多个点,则停止并指示为结束线。

例如,我有以下代码,但它不适用于其他文档,因为有时会有不同的结尾。

R 读取整个文档并仅识别到最后一个有许多点的位置。