python搜索PDF⽂件内容
我想做个⼩东东,需要读取pdf⽂件的⽂本内容,然后搜索某个关键词,返回这个关键词所在的页的页码,折腾我好⼏天了。⾸先看上了pypdf,啃了半天
洋⽂,发现这东西只能分割合并pdf⽂件,读取pdf⽂件的作者、标题等信息。然后⼜琢磨ReportLab,硬啃洋⽂,发现这东西主要是⽣成pdf⽂python怎么读取py文件
件,好像也没有读取的⽅法(⽣成和读取难道是不相⼲的吗?),于是⼜在论坛⼀阵狂搜,发现有仁兄跟我类似的需要,⾼⼈指点他去研究poppler,我放
狗⼀搜,到poppler的介绍页⾯,看到“The documentation is actually missing, help
wanted :) ”,⼼⾥就拔凉拔凉滴,俺是新⼿,有⽂档都要尚且研究半天,何况没⽂档啊,那是神⼈做的事啊,各位⼤侠,能否给指点⼀条明路,已经
折腾我好⼏天了,还没搞定?我只是想⽤python读取⼀下pdf⽂件的⽂本内容啊。
--~--~---------~--~----~------------~-------~--~----~
来⾃: `python-cn`:CPyUG ~ 华蟒⽤户组 | 发⾔:python-cn@...
退订: tinyurl/45a9tb /针对163/qq邮箱:tinyurl/4dg6hc
详情: le/group/python-cn
严正: 理解列表! 智慧提问! /moin/AskForHelp
-~----------~----~----~----~------~----~------~--~---
1,poppler-utils ⾥边有 pdftotext、pdftohtml、pdfinfo 等⼯具⽤于提取 pdf 内容 。
下载了pypoppler-0.10.,发现⾥⾯的⽂件没有setup.py,不能⽤python
setup.py install,⽽是linux下的install-sh的安装⽅式,我的是window xp系统,应该怎么安装呢?
安装 mingw、msys、python-dev,gtk-dev,pygtk-dev
不过应该还是 os.popen 调⽤ 简单
2,PDFminer⽐pdftoexe强太多了,正是我想要的。
----------------------------------------------------------------------------
最新免费的python开源项⽬
1、⽤python来做⼀个蜘蛛程序抓取⽹页,有了urllib库,真是太简单了。另外⽹页的解析也有相应的库sgmllib可以使⽤。不过还不知道python的sgmllib有没有类似 Jtidy 的规范html代码的功能,或者是有另外的库来⼲这事。
⽐较有名⽓的:
Harvest Man——le/p/harvestman-crawler/
HarvestMan is a modular, extensible and flexible web crawler program cum framework written in pure Python. HarvestMan can be used to download files from websites according to a number of customized rules and constraints. It can be used to find information from websites matching keywords or regular expressions.
The final goal of the project is to develop a full-fledged semantic personal data mining platform which can be used to retrieve information from the Internet in a highly customizable manner, so that one can fetch information from the web the way he wants it, when he wants it. For this, HarvestMan project will provide support for Web 2.0 and 3.0 technologies such as RSS, RDF, OWL etc. (这个⽬标还真是⼤啊,要是真的可以做到那就真是⽜逼。)
另外,还有⼀些⼩的项⽬,⽤Google code或者 sourceforge搜索,就可以到。
举个例⼦:
le/p/supercrawler/
2、对pdf⽂件的操作,C++,c#和java都有⼀些开源的类库可以使⽤。⽐如:pdflib,itext,pdfclown,pdfbox.
他们可以实现pdf⽂件的解析,并实现pdf与rtf html xml等格式之间的相互转换。
今天发现了⼀个可以操作pdf的python库: pdfminer.
le/p/pdfminerr/
不知道有没有其他的库。希望⾼⼿补充。
3、有了pdf的操作库,可以轻松实现对pdf⽂件内容的有⽬的的抽取。
这⾥有⼀个抽取⽂献的参考⽂献的例⼦:
pdf2ref
le/p/pdftoref/
This project aims to develop an efficient rule based extractor of entries of references, located in scientific articles in English language. The application takes a pdf file or a directory of pdf and then returns an html file, containing the list of all entries with their respective title. Moreover the title of the article cited is searched through Google Web Service to get the URL that identifying the article on the web. If the URL provides on the page a Bibtex entry, this will appear in the html output under the relative entries, stolen from some typical site like citeseer, ieeexlpore etc. The application does not make search over pdf file based on images.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。