forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprison_break_scrapper.py
More file actions
43 lines (34 loc) · 828 Bytes
/
prison_break_scrapper.py
File metadata and controls
43 lines (34 loc) · 828 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Scrapper for downloading prison break
series from an open server and putting them in a designated folder.
"""
import requests as req
from bs4 import BeautifulSoup as bs
import os
import subprocess
BASE_URL = 'http://dl.funsaber.net/serial/Prison%20Break/season%20'
def download_files(links, idx):
for link in links:
subprocess.call([
"aria2c",
"-s",
"16",
"-x",
"16",
"-d",
"season"+str(idx),
link
])
def main():
for i in range(1,5):
r = req.get(BASE_URL+str(i)+'/1080/')
soup = bs(r.text, 'html.parser')
link_ = []
for link in soup.find_all('a'):
if '.mkv' in link.get('href'):
link_.append(BASE_URL+str(i)+'/1080/'+link.get('href'))
if not os.path.exists('season'+str(i)):
os.makedirs('season'+str(i))
download_files(link_, i)
if __name__ == '__main__':
main()