Update locationdata.py

This commit is contained in:
SpudGunMan
2024-06-23 11:03:48 -07:00
parent a7047f1ad6
commit 83a99ead1f

View File

@@ -72,19 +72,25 @@ def get_weather(lat=0, lon=0):
if(weather_data.ok):
soup = bs.BeautifulSoup(weather_data.text, 'html.parser')
table = soup.find('div', id="detailed-forecast-body")
#get rows
rows = table.find_all('div', class_="row")
if table is None:
return "no weather data found on NOAA for your location"
else:
#get rows
rows = table.find_all('div', class_="row")
#extract data from rows
for row in rows:
#shrink the text
line = row.text.replace("Monday", "Mon") \
.replace("Tuesday", "Tue") \
.replace("Wednesday", "Wed") \
.replace("Thursday", "Thu") \
.replace("Friday", "Fri") \
.replace("Saturday", "Sat") \
.replace("Sunday", "Sun") \
line = row.text.replace("Monday", "Mon ") \
.replace("Tuesday", "Tue ") \
.replace("Wednesday", "Wed ") \
.replace("Thursday", "Thu ") \
.replace("Friday", "Fri ") \
.replace("Saturday", "Sat ") \
.replace("Today", "Today ") \
.replace("Tonight", "Tonight ") \
.replace("Tomorrow", "Tomorrow ") \
.replace("northwest", "NW") \
.replace("northeast", "NE") \
.replace("southwest", "SW") \