Skip to content

Commit

Permalink
Version 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amadejpapez authored Feb 6, 2021
1 parent b24a6ae commit 1e437ed
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions ApplSec.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import re
import emoji
import tweepy
import requests
from datetime import date
from bs4 import BeautifulSoup, SoupStrainer

api_key = "x"
api_secret_key = "x"
access_token = "x"
access_secret_key = "x"

auth = tweepy.OAuthHandler(api_key, api_secret_key)
auth.set_access_token(access_token, access_secret_key)
api = tweepy.API(auth)
api

updatesPage = requests.get("https://support.apple.com/en-us/HT201222").text
currentDateFormatOne = str(date.today().day) + " " + str(date.today().strftime("%B")[0:3]) + " " + str(date.today().year)
currentDateFormatTwo = str(date.today().strftime("%B")) + " " + str(date.today().day) + ", " + str(date.today().year)
Expand All @@ -15,14 +27,11 @@ def getData(link):
for x in link:
newPage = requests.get(x)
soup = BeautifulSoup(newPage.content, "html.parser")

# get the title of the new version
allHeaders = soup.find_all("h2")
newHeader.append(re.sub("<[^>]*?>","", str(allHeaders[1])))

# get the number of CVEs on the page
numberCVE.append(len(re.findall("CVE", str(soup))) - 1)

for x in newHeader:
# if there is macOS in the header take only the first part, not the full title
if "macOS" in x:
Expand All @@ -41,31 +50,28 @@ def getData(link):
# get only the new links from the page
newLinks = allLinks[22:len(re.findall(currentDateFormatOne, updatesPage)) + 22]
getData(newLinks)

# print results
results = "RELEASED TODAY:\n"
results = ":closed_lock_with_key: NEW UPDATES RELEASED :closed_lock_with_key:\n\n"
for x in newHeader:
results += x + " released with " + str(numberCVE[0]) + " security fixes\n"
results += "• " + x + " released with " + str(numberCVE[0]) + " security fixes\n"
numberCVE.pop(0)
print(results)
api.update_status(emoji.emojize("{}".format(results), use_aliases=True))


updatedLinks = []
for x in allLinks[22:42]:
# check if the last 20 update pages got any changes today
page = requests.get(x).text
search = "Entry added " + str(currentDateFormatTwo)

if search in page:
updatedLinks.append(x)

if updatedLinks != []:
newHeader.clear()
getData(updatedLinks)

# print results
results = "UPDATED TODAY:\n"
for x in newHeader:
results += x + " was released " + str(numberCVE[0]) + " security fixes\n"
numberCVE.pop(0)
print(results)
api.update_status(emoji.emojize(results))

0 comments on commit 1e437ed

Please sign in to comment.