How to extract text from an ebook or pdf?

Moneymaker$18

Newbie
Joined
Sep 27, 2017
Messages
4
Reaction score
2
Hey guys, I’ve been a long time lurker here but recently I created a website and have a question that may seem simple. Is there a way to scrape or extract text from an e-book or pdf? I want to be able to target an exact keyword or words. Would this require some type of Python script or is there something already available? Thanks!
 
Hey guys, I’ve been a long time lurker here but recently I created a website and have a question that may seem simple. Is there a way to scrape or extract text from an e-book or pdf? I want to be able to target an exact keyword or words. Would this require some type of Python script or is there something already available? Thanks!
You are correct, use python... PyPDF2 module should do the job...

Here's a sample code for u:
Python:
import PyPDF2
fhandle = open(r'D:\examplepdf.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(fhandle)
pagehandle = pdfReader.getPage(0)
print(pagehandle.extractText())
 
If you want to exact ebook/PDF file to text then many websites/platforms can be done with this .
But you want a specified word/text then you should use tool/Python .
 
You are correct, use python... PyPDF2 module should do the job...

Here's a sample code for u:
Python:
import PyPDF2
fhandle = open(r'D:\examplepdf.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(fhandle)
pagehandle = pdfReader.getPage(0)
print(pagehandle.extractText())
I just bookmarked . Thank you for sharing this bro .
It will help me a lot .
 
You are correct, use python... PyPDF2 module should do the job...

Here's a sample code for u:
Python:
import PyPDF2
fhandle = open(r'D:\examplepdf.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(fhandle)
pagehandle = pdfReader.getPage(0)
print(pagehandle.extractText())
I’ll check this out, thank you!
 
You can convert the pdf to some other form like DOC, then copy paste the text you want from the DOC file.
 
Back
Top