【问题标题】:How can I scrape several pages of a pdf?我怎样才能刮掉pdf的几页?
【发布时间】:2021-09-30 14:13:35
【问题描述】:

我的代码是这样的:

df = tabula.read_pdf('test.pdf', pages = ['all'])[0]

df.head()

df.to_excel('test.xlsx')`

当我运行它时,我的 Excel 中只有第一页...

【问题讨论】:

    标签: python excel pdf spyder screen-scraping


    【解决方案1】:

    您阅读了包含所有页面的整个 pdf,但您获取了第一个元素。

    df = tabula.read_pdf('test.pdf', pages = ['all'])[0]
                                                     ^^^
    

    我认为您必须将其删除并连接它才能使所有页面都表现出色。类似的东西:

    dfs = tabula.read_pdf(self.file, pages='all')
    df = pd.concat(dfs)
    df.to_excel("filename.xlsx")
    

    Here 是一篇如何处理 pdf 的好文章

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-21
      • 2018-08-29
      • 1970-01-01
      • 2019-01-18
      • 1970-01-01
      • 2021-10-08
      • 2020-04-06
      • 1970-01-01
      相关资源
      最近更新 更多