-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvanilla.py
22 lines (18 loc) · 1.19 KB
/
vanilla.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests
from bs4 import BeautifulSoup
from typing import (AnyStr, List, Dict)
from util import Util
from custom_typing import (JsonDict, RequestResponse, String)
def get_vanilla() -> JsonDict:
response: RequestResponse = requests.get('https://getbukkit.org/download/vanilla')
soup: BeautifulSoup = BeautifulSoup(response.text, 'html.parser')
downloadResponse: RequestResponse = requests.get(soup.select('#downloadr')[0]['href'])
downloadSoup: BeautifulSoup = BeautifulSoup(downloadResponse.text, 'html.parser')
downloadUrl: String = downloadSoup.select('#get-download > div > div > div > div > h2 > a')[0]['href']
json: JsonDict = {
'version': Util.oneKey('#download > div > div > div > div:nth-child(1) > div > div:nth-child(1) > h2', soup),
'size': Util.oneKey('#download > div > div > div > div:nth-child(1) > div > div.col-sm-2 > h3', soup),
'date': Util.dateFormatter(Util.oneKey('#download > div > div > div > div:nth-child(1) > div > div:nth-child(3) > h3', soup)),
'download_url': downloadUrl,
'boost_download_url': downloadUrl.replace('https://launcher.mojang.com', 'https://download.mcbbs.net')}
return json