forked from hcjohn463/JableTVDownload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
args.py
33 lines (26 loc) · 1.03 KB
/
args.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
31
32
33
import argparse
from bs4 import BeautifulSoup
import random
from urllib.request import Request, urlopen
from config import headers
import re
def get_parser():
parser = argparse.ArgumentParser(description="Jable TV Downloader")
parser.add_argument("--random", type=bool, default=False,
help="Enter True for download random ")
parser.add_argument("--url", type=str, default="",
help="Jable TV URL to download")
parser.add_argument("--all-urls", type=str, default="",
help="Jable URL contains multiple avs")
return parser
def av_recommand():
headers = {'User-Agent': 'Mozilla/5.0'}
url = 'https://jable.tv/'
request = Request(url, headers=headers)
web_content = urlopen(request).read()
# 得到繞過轉址後的 html
soup = BeautifulSoup(web_content, 'html.parser')
h6_tags = soup.find_all('h6', class_='title')
av_list = re.findall(r'https[^"]+', str(h6_tags))
return random.choice(av_list)
# print(av_recommand())