Commit 07d89120 authored by Sanjna's avatar Sanjna

new codes

parent 52b4abe4
No preview for this file type
CSE Git link:
https://git.cse.iitb.ac.in/sanjnamohan/eBookmaker
Team Members:
Sanjna Mohan (20305R006) : Merging of codes, Epub creation, Documentation
Manjusree MP (203059007) : Content extraction from links and saving in required format for epub creation
Pooja Gayakwad (203050076) : Merging of codes and GUI Implementation
Snehlata Yadav (203050075) : Nested links extraction from webpage of inputted URL
Motivation:
While going through vast tutorials on the web, sometimes it becomes tedious to go to all the links and read.
Moreover, the availability only in the presence of Internet makes it difficult for future reference.
We have come up with this project to ease the process and to download the tutorial onto our computers as an eBook.
This way, not only we get the contents in an organized manner, but also we can avail it as and when we require.
Our solution is a GUI application that takes the particular URL from the user as input, and use web scraping to get the contents as a centralized epub document which can be saved at our convenience.
NOTE:
This is a Windows application.
How to use:
Clone the repository onto your system:
git clone https://sanjnamohan@git.cse.iitb.ac.in/sanjnamohan/eBookmaker.git
For executing:
NOTE:
Do not change the directory structure after cloning.
Make sure the relevant libraries are installed:
pip install -r requirements.txt
Double click on epub.exe and wait for few seconds till the GUI appears.
Once the GUI appears, enter the URL of which the document is to be created and select the destination folder using "Browse" button.
Select either of "Single Page" or "Complete Tutorial" radio buttons and click "Generate Epub" button.
The generated eBook would be present at the set destination folder.
Alternatively:
Make sure the relevant libraries are installed:
pip install -r requirements.txt
The source code is available in epub.py. To execute directly from the source, run:
python epub.py
No preview for this file type
source/cover.jpg

58.4 KB | W: | H:

source/cover.jpg

40.6 KB | W: | H:

source/cover.jpg
source/cover.jpg
source/cover.jpg
source/cover.jpg
  • 2-up
  • Swipe
  • Onion skin
File added
...@@ -115,7 +115,7 @@ def generate_epub(url, path): ...@@ -115,7 +115,7 @@ def generate_epub(url, path):
font = ImageFont.truetype("arial.ttf", size=20) font = ImageFont.truetype("arial.ttf", size=20)
MAX_W, MAX_H = img.size MAX_W, MAX_H = img.size
w, h = draw.textsize(book_title, font=font) w, h = draw.textsize(book_title, font=font)
draw.text(((MAX_W - h) / 2, (MAX_H - h) / 2), book_title, fill="black", font=font, anchor="ms", align="center") draw.text(((MAX_W - w) / 2, (MAX_H - h) / 2), book_title, fill="white", font=font, anchor="ms", align="center")
img.save('cover-out.jpg') img.save('cover-out.jpg')
book.set_cover("cover-out.jpg", open('cover-out.jpg', 'rb').read()) book.set_cover("cover-out.jpg", open('cover-out.jpg', 'rb').read())
...@@ -498,12 +498,14 @@ def extract_links(url, path, doctype=1): ...@@ -498,12 +498,14 @@ def extract_links(url, path, doctype=1):
ulist = [] ulist = []
try: try:
url = url.strip()
r = requests.get(url) r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser') soup = BeautifulSoup(r.text, 'html.parser')
title = soup.find("title") title = soup.find("title")
global book_title global book_title
global textfilepath global textfilepath
book_title = title.string book_title = title.string
print("Book title: {}".format(book_title))
textfilepath = path + "/__links__.txt" textfilepath = path + "/__links__.txt"
if (doctype == 2): if (doctype == 2):
...@@ -730,7 +732,7 @@ def extract_links(url, path, doctype=1): ...@@ -730,7 +732,7 @@ def extract_links(url, path, doctype=1):
except Exception as e: except Exception as e:
return "Exception" return "Exception"
else: else:
pb_label.set("Now saving links in a text file..") pb_label.set("Now processing extracted links in a text file..")
popup.update() popup.update()
sleep(5/1000) # lauch task sleep(5/1000) # lauch task
progress = 30 progress = 30
......
NOTE:
This is a Windows application.
How to use:
Clone the repository onto your system:
git clone https://sanjnamohan@git.cse.iitb.ac.in/sanjnamohan/eBookmaker.git
For executing:
NOTE:
Do not change the directory structure after cloning.
Make sure the relevant libraries are installed:
pip install -r requirements.txt
Double click on epub.exe and wait for few seconds till the GUI appears.
Once the GUI appears, enter the URL of which the document is to be created and select the destination folder using "Browse" button.
Select either of "Single Page" or "Complete Tutorial" radio buttons and click "Generate Epub" button.
The generated eBook would be present at the set destination folder.
Alternatively:
Make sure the relevant libraries are installed:
pip install -r requirements.txt
The source code is available in epub.py. To execute directly from the source, run:
python epub.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment