File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ This is the readme file of this project.
2
+ It's a basic PDF downloader from a certain link.
3
+
4
+
5
+ Install required dependancies
6
+
7
+ python -m pip install ./requirements.txt
8
+
9
+ How to run :
10
+
11
+ python pdf.py
Original file line number Diff line number Diff line change
1
+ import os
2
+ import requests
3
+ from urllib .parse import urljoin
4
+ from bs4 import BeautifulSoup
5
+
6
+ #Put the link from which you need to download all the pdf
7
+ url = ""
8
+
9
+ #If there is no such folder, the script will create one automatically
10
+ folder_location = r'./NewFolder'
11
+ if not os .path .exists (folder_location ):os .mkdir (folder_location )
12
+
13
+ response = requests .get (url )
14
+ soup = BeautifulSoup (response .text , "html.parser" )
15
+ for link in soup .select ("a[href$='.pdf']" ):
16
+ #Name the pdf files using the last portion of each link which are unique in this case
17
+ filename = os .path .join (folder_location ,link ['href' ].split ('/' )[- 1 ])
18
+ with open (filename , 'wb' ) as f :
19
+ f .write (requests .get (urljoin (url ,link ['href' ])).content )
Original file line number Diff line number Diff line change
1
+ beautifulsoup4 == 4.10.0
2
+ requests == 2.18.4
Original file line number Diff line number Diff line change @@ -92,3 +92,4 @@ The contribution guidelines are as per the guide [HERE](https://github.com/larym
92
92
| 49 | [ Pomodoro App] ( https://github.com/HarshitRV/Python-project-Scripts/tree/main/Pomodoro-App ) | [ HarshitRV] ( https://github.com/HarshitRV )
93
93
| 49 | [ BullsAndCows] ( https://github.com/HarshitRV/Python-project-Scripts/tree/main/BullsAndCows ) | [ JerryChen] ( https://github.com/jerrychen1990 )
94
94
| 50 | [ Minesweeper AI] ( https://github.com/nrp114/Minsweeper_AI ) | [ Nisarg Patel] ( https://github.com/nrp114 )
95
+ | 51 | [ PDF Downloader] ( https://github.com/Sdccoding/Python-project-Scripts/tree/main/PDF_Downloader ) | [ Souhardya Das Chowdhury] ( https://github.com/Sdccoding )
You can’t perform that action at this time.
0 commit comments