performance - not splitting again and again with new line

This commit is contained in:
David Bures
2024-06-26 13:00:04 -07:00
parent f5692882b4
commit 436d42a72f
+5 -3
View File
@@ -99,12 +99,14 @@ def get_weather(lat=0, lon=0, unit=0):
rows = table.find_all('div', class_="row")
# extract data from rows
for row in rows:
for index, row in enumerate(rows):
# shrink the text
line = replace_weather(row.text)
# only grab a few days of weather
if len(weather.split("\n")) < DAYS_OF_WEATHER:
weather += line + "\n"
print(f"weather: {index}")
weather += line + "\n"
if index >= DAYS_OF_WEATHER-1:
break
# trim off last newline
weather = weather[:-1]