-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtests.py
30 lines (27 loc) · 767 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from urllib.request import urlopen
from bs4 import BeautifulSoup
class Downloader:
def scrape(self, url):
src = urlopen(url)
codebase = BeautifulSoup(src, 'html.parser')
y = codebase.findAll("a")
flag = -1
for i in y:
temp = i.get("href")
if ".mp4" in temp:
flag = 1
break
else:
flag = 0
if flag == 1:
print("Successful found download links")
return 1
else:
print("Links not found")
return 0
def start():
download = Downloader()
downloadURL = "https://nptel.ac.in/courses/106/106/106106213/"
download.scrape(downloadURL)
if __name__ == "__main__":
start()