[pan] Support PAN-OS as well

This commit is contained in:
Nemo
2022-10-10 17:13:42 +05:30
committed by Nemo
parent 0c04452693
commit 0a992286b2
2 changed files with 34 additions and 19 deletions

34
src/palo-alto-networks.py Normal file
View File

@@ -0,0 +1,34 @@
import json
import urllib.request
import datetime
from bs4 import BeautifulSoup
URL = "https://www.paloaltonetworks.com/services/support/end-of-life-announcements/end-of-life-summary"
ID_MAPPING = {
"pan-os-panorama": "pan-os",
"globalprotect": "pan-gp"
}
def update_releases(html_id, file):
list = {}
with urllib.request.urlopen(URL, data=None, timeout=5) as response:
soup = BeautifulSoup(response, features="html5lib")
table = soup.find(id=html_id)
for tr in table.findAll('tr')[3:]:
td_list = tr.findAll('td')
version = td_list[0].get_text()
try:
month,date,year = td_list[1].get_text().split('/')
abs_date = f"{year}-{month:0>2}-{date:0>2}"
except Exception as e:
date = datetime.datetime.strptime(td_list[1].get_text(), "%B %d, %Y")
abs_date = date.strftime("%Y-%m-%d")
list[version] = abs_date
with open('releases/%s.json' % file, 'w') as f:
f.write(json.dumps(list, indent=2))
for html_id in ID_MAPPING:
update_releases(html_id, ID_MAPPING[html_id])

View File

@@ -1,19 +0,0 @@
import json
import urllib.request
from bs4 import BeautifulSoup
URL = "https://www.paloaltonetworks.com/services/support/end-of-life-announcements/end-of-life-summary"
list = {}
with urllib.request.urlopen(URL, data=None, timeout=5) as response:
soup = BeautifulSoup(response, features="html5lib")
table = soup.find(id='globalprotect')
for tr in table.findAll('tr')[3:]:
td_list = tr.findAll('td')
version = td_list[0].get_text()
month,date,year = td_list[1].get_text().split('/')
abs_date = f"{year}-{month:0>2}-{date:0>2}"
list[version] = abs_date
with open('releases/pan-gp.json', 'w') as f:
f.write(json.dumps(list, indent=2))