mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-03-28 17:32:36 +01:00
Update locationdata.py
This commit is contained in:
@@ -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") \
|
||||
|
||||
Reference in New Issue
Block a user