我最近开始为我的实习而抓取(和一般的编程),我遇到了PDF抓取。每次我尝试用R读取扫描的pdf时,我都无法让它工作。我尝试过使用file.choose()函数,但没有用。我是否需要更改我的目录,或者如何将pdf从我的文件中获取到R中?代码看起来像这样:
> library(pdftools)
> text=pdf_text("C:/Users/myname/Documents/renewalscan.pdf")
> text
[1] ""此外,使用pdftables可以让我了解以下内容:
> library(pdftables)
> convert_pdf("C:/Users/myname/Documents/renewalscan.pdf","my.csv")
Error in get_content(input_file, format, api_key) :
Bad Request (HTTP 400).发布于 2018-06-08 04:52:23
您应该使用包pdftools和pdftables。
如果您正在尝试读取pdf中的文本,则使用pdf_text()函数。里面的内容是pdf的路径(在你的电脑或网站中)。例如
tt = pdf_text("C:/Users/Smith/Documents/my_file.pdf")如果您能更详细地说明,并给我们提供可重现的示例,那就更好了。
发布于 2019-03-29 15:33:37
要使用PDFTables R包,您需要运行以下命令:
convert_pdf('test/index.pdf', output_file = NULL, format = "xlsx-single", message = TRUE, api_key = "insert_API_key")发布于 2019-09-24 23:51:43
如果您希望获得表格数据,可以尝试使用tabulizer。这是一个完整的代码教程:https://www.business-science.io/code-tools/2019/09/23/tabulizer-pdf-scraping.html
基本上,您可以使用本教程中的代码:
library(tabulizer)
extract_tables(
file = "2019-09-23-tabulizer/endangered_species.pdf",
method = "decide",
output = "data.frame")https://stackoverflow.com/questions/50749759
复制相似问题