-
Notifications
You must be signed in to change notification settings - Fork 5
/
tvos.py
36 lines (28 loc) · 1.17 KB
/
tvos.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
34
35
36
import requests
import re
base_url = 'https://support.apple.com/en-us/HT201222'
def get_latest_security_update():
response = __send_request__('/')
if response.status_code == 200:
result = response.text
ul_list = re.findall('The latest version of tvOS is (.+?)\. Learn', result)
if len(ul_list) == 0 or (len(ul_list) == 1 and ul_list[0].find('and') != -1):
ul_list = re.findall('The latest version of tvOS is (.+?), and', result)
if len(ul_list) == 0:
print("Unable to parse ul_list.")
latest_ver = ul_list[0]
link_no_cve_re = '<td>tvOS {0}<br>\\s+<span class="note">(.+?)</span></td>'.format(latest_ver)
link_cve_re = '<td><a href="(.+?)">tvOS {0}</a></td>'.format(latest_ver)
td_list = re.findall(link_no_cve_re, result)
if len(td_list) == 1:
latest_link = td_list[0]
else:
td_list = re.findall(link_cve_re, result)
latest_link = td_list[0]
return latest_ver, latest_link
return ''
def __send_request__(path: str):
response = requests.get(base_url + path)
return response
def do():
print(get_latest_security_update())