From 84d19c69541e6dd609b70708f65e8b179da7fda4 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Sun, 21 Nov 2021 13:02:15 -0700 Subject: [PATCH] Add files via upload --- azpowerball.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 azpowerball.py diff --git a/azpowerball.py b/azpowerball.py new file mode 100644 index 0000000..3158c08 --- /dev/null +++ b/azpowerball.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +# Import BeautifulSoup +from bs4 import BeautifulSoup +import requests + +# Arizona Powerball API URL +myUrl = 'https://powerball.com/api/v1/numbers/powerball/recent10?_format=xml' + +try: + # Get winning Arizona Powerball numbers from powerball.com + response = requests.get(myUrl) + + # If we receive a response, proceed... + if response: + + # Store the response from the server into a bowl of soup + soup = BeautifulSoup(response.text, 'lxml') # load the response into BeautifulSoup + + # parse out the winning numbers + winningNumbers = soup.find('field_winning_numbers').contents + + # parse out the drawing date + drawingDate = soup.find('field_draw_date').contents + + # print out the winning numbers and drawing date + print(*winningNumbers,*drawingDate) + +# Notify user if we fail to get a response from server... +except Exception as e: + print('No response from powerball.com.') \ No newline at end of file