Home > Software design >  How to automate the process of copy pasting certain sections of HTML for a lot of web pages?
How to automate the process of copy pasting certain sections of HTML for a lot of web pages?

Time:04-02

I want to collect all sections of a web book into a single HTML file to later turn it into an ePUB (eBook) using calibre.

Here's the web book. On the web it is organized into a lot of parts. So far I've been copy pasting the relevant HTML sections using chrome devtools to organize it into one HTML file. I think there might be a better way to do it in python (or in any other way).

CodePudding user response:

You may use this libruary for python to parse and get html codes from any sites like this:

from bs4 import BeautifulSoup
import requests

html = requests.get('https://www.wisdomlib.org/hinduism/book/a-history-of-indian-philosophy-volume-2')
soup = BeautifulSoup(html.content, "html.parser")

element = soup.find("a")
source = element.prettify()
  • Related