How do you copy and paste the text from every page of a book from Google books View plain text option:

For example: http://books.google.com/books?id=r70CAAAAQAAJ&printsec=frontcover&dq=true+devotion+blessed+virgin&lr=&as_brr=1&ei=cwB1SZOcI5j4MO6c-bkM

instead of doing it by hand.

Also how do you open a series of table of contents like this: http://www.catholictradition.org/Classics/humility-text.htm
and then
1. copy paste on one page like this: http://www.catholictradition.org/Classics/humility-text1.htm#4

2. copy paste to this form: http://www.creationscience.com/onlinebook/ (table of contents on the side while you view the text on main page)

Member #361407 commented: Pointless question +0

Dani AI

Generated

Short summary and a legal note: do not bulk-copy books unless the text is public-domain or you have permission. Google Books exposes preview/full-download status through its API and its Terms of Service control what you may do; prefer the API or any offered PDF/epub download rather than scraping the viewer. As suggested, downloading an available PDF is usually the simplest lawful route. (books.google.com)

If the Books API shows an available pdf or epub download, download that programmatically and extract text (PDF -> text with pdfminer.six or PyPDF2, EPUB -> unzip/read). Example pattern: download with Requests, then write or convert and assemble into a .docx with python-docx.

import requests
from docx import Document

r = requests.get(download_url, stream=True)
with open('book.pdf', 'wb') as f:
    for chunk in r.iter_content(8192):
        f.write(chunk)

# extract text from the PDF with a PDF library, then:
doc = Document()
doc.add_paragraph(extracted_text)
doc.save('book.docx')

Use the Books API accessInfo fields to discover downloadLink/acsTokenLink before automating. (developers.google.com)

When the site is plain HTML (table-of-contents pages), requests + BeautifulSoup is fast and reliable; for pages where you must click “View plain text” or the content is rendered by JS, use Selenium to automate the browser and extract the page text. Keep scripts slow and polite (rate-limit, obey robots.txt) and never try to bypass protections. Example (Selenium):

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get(book_web_reader_url)
driver.find_element(By.LINK_TEXT, "View plain text").click()
text = driver.find_element(By.TAG_NAME, "body").text
driver.quit()

Use requests+bs4 for static TOC scraping and follow site rules. (selenium.dev)

Practical checklist: 1) confirm rights (TOS / public domain), 2) prefer Google Books API or offered downloads, 3) if scraping, obey robots.txt and rate limits, 4) extract with PDF/EPUB tooling and assemble with python-docx. This respects both legality and long-term reliability. (books.google.com)

Recommended Answers

All 9 Replies

why is this in the python forum?

why is this in the python forum?

Because he thinks we'll do his homework for him.

Because he thinks we'll do his homework for him.

This isn't h/w.

still has nothing to do with python

still has nothing to do with python

I know a tiny amount of python so I wanted people to help me.

For the google books,
I know this much: put raw_input #enter web address.

But I don't know this:

code for clicking on "view plain text"

code for copying and pasting from one page, to a word file,
then press spacebar (goes down one page)
then repeat until end of the book is reached.

So where should I post something like this to get help on programming?

They have a PDF download link. Why not use that?

They have a PDF download link. Why not use that?

When it is put into text form, one can highlight the important passages, and copy and paste the important passages.

Member Avatar for Member #361407

then why don't you do that anyway, just go through it and copy those!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.