下载一个PDF并将提取的文本发送到另一个带有Allias的脚本(标题、描述、日期…)

2024-09-27 22:21:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用了模块slate,它基于pdfminer。你知道吗

下面的脚本可以正确阅读第1页和第2页上的文章,但是有许多页面和多个pdf文件,因此布局可能会有所不同,pdf有时会在下一页运行一篇文章,因此它不会放下来,因此显示不好。 可能会有一个for循环必须建立,但我不知道具体如何。 for循环可能是必须构建的,但我不知道具体如何构建。你知道吗

也可以将项目留在数据库中,但首先必须将其发送到筛选器脚本。 那么,如果这些项目可以分为标题、描述、日期文章、添加日期、url和区域,那会有用吗?你知道吗

PDF文件:


import slate

global artikelIndexStr

with open('report.pdf') as f:
doc = slate.PDF(f)

report = slate.PDF(f)

pdfstring = doc[1] + doc[2] + doc[3] + doc[4] + doc[5] + doc[6] + doc[7] + doc[8] + doc[9] + doc[10] + doc[11] + doc[12] + doc[13] + doc[14] + doc[15] + doc[16] + doc[17] + doc[18] + doc[19] + doc[20]

# print pdfstring

f3 = 'Even iets'        
f3 = pdfstring
temparray = []
temparray2 = []
artikelIndex = 1
artikelIndexStr = ""


while f3 != "":

    f1, f2, f3 = f3.partition("[Return to top]")

    temparray.append(f1)

    print len(temparray)

nieuweIndex = "" + temparray[0]

print nieuweIndex

a1, a2, a3 = nieuweIndex.partition("1. ")
b1, b2, b3 = a3.partition("Source: ")
c1, c2, c3 = b3.partition("2. ")
d1, d2, d3 = c3.partition("Source: ") 
e1, e2, e3 = d3.partition("3.") 
g1, g2, g3 = e3.partition("Source: ") 
h1, h2, h3 = g3.partition("4.") 
i1, i2, i3 = h3.partition("Source: ") 
j1, j2, j3 = i3.partition("5.") 
k1, k2, k3 = h3.partition("Source: ") 
l1, l2, l3 = i3.partition("6.")

print ""
print b1
print ""
print c1
print ""
print d1
print ""
print e1
print ""
print g1
print ""
print h1
print ""
print i1
print ""
print j1
print ""
print k1
print ""
print l1

Tags: reportsourcedocpdf文章dailypartitionprint

热门问题