Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 578f264

Browse files
Merge pull request avinashkranjan#513 from vikashkumar2020/SD
issue avinashkranjan#498 slideshare downloader added
2 parents 208d5ce + a7b6e45 commit 578f264

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

‎Slideshare downloader/README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Slideshare Downloader
2+
## Description
3+
A Script to download slides from Slideshare as pdf from URL.
4+
- This is can be used for implementations as one of the features.
5+
6+
### Language
7+
- [X] Python
8+
9+
### Instructions to run this application
10+
11+
1. Python 3 must be installed in your system.
12+
13+
- For first time, run this in terminal or powershell
14+
```
15+
pip3 install -r requirements.txt
16+
```
17+
2. It will download all the required modules
18+
19+
- Now run the below command
20+
```
21+
python slideshare_downloader.py
22+
```
23+
- After that follow the instructions on screen and enter the URL.
24+
- then enter the file name for your slides pdf.
25+
26+
Finally you will get the slides pdf file in same folder with file name as you provided in above step.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bs4
2+
requests
3+
urllib3
4+
img2pdf
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# slideshare downloader
2+
from bs4 import BeautifulSoup
3+
import requests
4+
import itertools
5+
import threading
6+
import time
7+
import sys
8+
import urllib.request
9+
import img2pdf
10+
import os
11+
12+
task = False
13+
process = "getting the slides "
14+
15+
16+
def animate():
17+
for i in itertools.cycle(['|', '/', '-', '\\']):
18+
if task:
19+
break
20+
sys.stdout.write('\r' + process + i)
21+
sys.stdout.flush()
22+
time.sleep(0.1)
23+
24+
25+
t = threading.Thread(target=animate)
26+
27+
28+
def get_image_list(url):
29+
code = requests.get(url)
30+
soup = BeautifulSoup(code.text, "html.parser")
31+
print(f"Title: {soup.title.get_text()}")
32+
imgs = soup.find_all("img")
33+
img_urls = []
34+
for temp_url in imgs:
35+
temp_link = temp_url.get("data-full")
36+
if temp_link is not None:
37+
img_urls.append(temp_link)
38+
return img_urls
39+
40+
41+
def slides_capture(links):
42+
pg_no = 1
43+
os.makedirs(".cache", exist_ok=True)
44+
all_slides = []
45+
for link in links:
46+
print(f"fetching (slide{pg_no})")
47+
file = f"slide{pg_no}.jpg"
48+
urllib.request.urlretrieve(link, ".cache/"+file)
49+
all_slides.append(".cache/"+file)
50+
pg_no = pg_no+1
51+
return all_slides
52+
53+
54+
def combine(all_slides):
55+
output_name = input("\n\n Enter the name for pdf file of slides (without extension):")
56+
with open(output_name+".pdf", "wb") as f:
57+
f.write(img2pdf.convert(all_slides))
58+
for i in all_slides:
59+
os.remove(i)
60+
61+
62+
print("Enter the URL of slides below:")
63+
main_link = input()
64+
t.start()
65+
all_urls = get_image_list(main_link)
66+
if len(all_urls) == 0:
67+
print("Sorry no downloadable slides found")
68+
task = True
69+
else:
70+
print(f"Total no of Slides found: {len(all_urls)}")
71+
all_slides = slides_capture(all_urls)
72+
task = True
73+
combine(all_slides)
74+
print("All set your file is ready")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /