This commit is contained in:
2025-11-29 10:08:32 +00:00
parent 1c2d8a3b6d
commit 6dd745f46c
10 changed files with 168 additions and 143 deletions

View File

@@ -8,6 +8,7 @@ import pandas as pd
import requests import requests
import xmltodict import xmltodict
import datetime import datetime
from html import escape
from tabulate import tabulate from tabulate import tabulate
allobs = [] allobs = []
@@ -26,7 +27,14 @@ try:
data = xmltodict.parse(response.content.decode('utf-8')) # Explicitly decode as UTF-8 data = xmltodict.parse(response.content.decode('utf-8')) # Explicitly decode as UTF-8
try: try:
reports = data['Cocorahs']['DailyPrecipReports']['DailyPrecipReport'] daily_reports = data.get('Cocorahs', {}).get('DailyPrecipReports')
if daily_reports is None:
print(f"No reports found for state {state}")
continue
reports = daily_reports.get('DailyPrecipReport')
if reports is None:
print(f"No reports data found for state {state}")
continue
# Handle case where reports might be a single dict or a list # Handle case where reports might be a single dict or a list
if isinstance(reports, dict): if isinstance(reports, dict):
reports = [reports] reports = [reports]
@@ -36,7 +44,8 @@ try:
allobs.append(report) allobs.append(report)
else: else:
for county in eval(state + 'counties'): for county in eval(state + 'counties'):
if county in report['StationNumber']: station_number = report.get('StationNumber', '')
if county in station_number:
allobs.append(report) allobs.append(report)
except (KeyError, TypeError) as e: except (KeyError, TypeError) as e:
print(f"Error processing data for state {state}: {e}") print(f"Error processing data for state {state}: {e}")
@@ -65,6 +74,50 @@ try:
tablefmt='plain' # Changed to 'plain' for simpler text output tablefmt='plain' # Changed to 'plain' for simpler text output
)) ))
# Write HTML table to today.html
html_content = """<!DOCTYPE html>
<html>
<head>
<title>Cocorahs Weather Data - """ + datewanted + """</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; }
tr:nth-child(even) { background-color: #f9f9f9; }
</style>
</head>
<body>
<h1>Cocorahs Weather Data - """ + datewanted + """</h1>
<table>
<thead>
<tr>
<th>Date/Time of Ob (Z)</th>
<th>Station Number</th>
<th>Station Name</th>
<th>New Precip</th>
<th>New Snow</th>
<th>Snow Depth</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
"""
for row in finalobs:
html_content += " <tr>\n"
for cell in row:
html_content += f" <td>{escape(str(cell))}</td>\n"
html_content += " </tr>\n"
html_content += """ </tbody>
</table>
</body>
</html>"""
with open('/var/www/html/work/today.html', 'w', encoding='utf-8') as f:
f.write(html_content)
except requests.RequestException as e: except requests.RequestException as e:
print(f"Error fetching data: {e}") print(f"Error fetching data: {e}")
except Exception as e: except Exception as e:

View File

@@ -133,7 +133,7 @@
<a href="db.html" class="w3-button w3-black">WU obs</a> <a href="db.html" class="w3-button w3-black">WU obs</a>
<a href="5min.html" class="w3-button w3-black">5m ASOS obs</a> <a href="5min.html" class="w3-button w3-black">5m ASOS obs</a>
<a href="outagemap.html" class="w3-button w3-black">Power Outages</a> <a href="outagemap.html" class="w3-button w3-black">Power Outages</a>
<a href="today.txt" class="w3-button w3-black">CoCoRaHS Remarks</a> <a href="today.html" class="w3-button w3-black">CoCoRaHS Remarks</a>
<a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a> <a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a>
<!-- <a href="http://stoat.org/work/db.html" class="w3-button w3-black">Wunderground Obs</a>--> <!-- <a href="http://stoat.org/work/db.html" class="w3-button w3-black">Wunderground Obs</a>-->

View File

@@ -67,7 +67,7 @@ input[type=text] {
<a href="db.html" class="w3-button w3-black">WU obs</a> <a href="db.html" class="w3-button w3-black">WU obs</a>
<a href="5min.html" class="w3-button w3-black">5m ASOS obs</a> <a href="5min.html" class="w3-button w3-black">5m ASOS obs</a>
<a href="outage.html" class="w3-button w3-black">Power Outages</a> <a href="outage.html" class="w3-button w3-black">Power Outages</a>
<a href="today.txt" class="w3-button w3-black">CoCoRaHS Remarks</a> <a href="today.html" class="w3-button w3-black">CoCoRaHS Remarks</a>
<a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a> <a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a>
<label for="numberofimages">Number of Frames for Loop</label> <label for="numberofimages">Number of Frames for Loop</label>
<input type="number" id="numberofimages" name="numberofimages" onchange="setcams()"> <input type="number" id="numberofimages" name="numberofimages" onchange="setcams()">

File diff suppressed because one or more lines are too long

View File

@@ -51,7 +51,7 @@ for k in fetcharray:
metardict = content.json() metardict = content.json()
print(metardict) #print(metardict)
for i in metardict: for i in metardict:

View File

@@ -193,8 +193,8 @@ Collected 293 stories. Processing and inserting...
- Impact[0] NLP[0.0]: West Virginia National Guard member Sarah Beckstrom dies after DC shooting, governor says - Impact[0] NLP[0.0]: West Virginia National Guard member Sarah Beckstrom dies after DC shooting, governor says
- Impact[0] NLP[0.0]: High School Football Scores: Week 15 - Impact[0] NLP[0.0]: High School Football Scores: Week 15
- Impact[50] NLP[0.0]: 'There will be justice': W.Va. governor addresses state's National Guard troops in DC - Impact[50] NLP[0.0]: 'There will be justice': W.Va. governor addresses state's National Guard troops in DC
- Impact[0] NLP[0.0]: Refugee vetting under renewed scrutiny after D.C. shooting
- Impact[50] NLP[0.0]: Police: Ohio man accused of breaking into the restaurant he worked at, stealing cash - Impact[50] NLP[0.0]: Police: Ohio man accused of breaking into the restaurant he worked at, stealing cash
- Impact[0] NLP[0.0]: Refugee vetting under renewed scrutiny after D.C. shooting
- Impact[0] NLP[0.0]: Trump calls for migration pause after D.C. shooting, targets MN governor with slur - Impact[0] NLP[0.0]: Trump calls for migration pause after D.C. shooting, targets MN governor with slur
- Impact[50] NLP[0.0]: Deployment of WVNG under additional scrutiny following D.C. shooting - Impact[50] NLP[0.0]: Deployment of WVNG under additional scrutiny following D.C. shooting
- Impact[87] NLP[0.09]: Kanawha teen's tragic death highlights the rising threat of sextortion across the country - Impact[87] NLP[0.09]: Kanawha teen's tragic death highlights the rising threat of sextortion across the country
@@ -270,21 +270,21 @@ Collected 293 stories. Processing and inserting...
- Impact[0] NLP[0.0]: Bristol community mourns after double homicide on Lily Street - Impact[0] NLP[0.0]: Bristol community mourns after double homicide on Lily Street
- Impact[0] NLP[0.0]: Bristol Rhythm & Roots Reunion unveils initial 25th anniversary lineup - Impact[0] NLP[0.0]: Bristol Rhythm & Roots Reunion unveils initial 25th anniversary lineup
- Impact[0] NLP[0.0]: New $80M resort opens in Pigeon Forge, a big draw for Tennessee vacationers - Impact[0] NLP[0.0]: New $80M resort opens in Pigeon Forge, a big draw for Tennessee vacationers
- Impact[0] NLP[0.0]: 7 women facing contraband-related charges in Washington County, Tennessee, authorities say
- Impact[0] NLP[0.0]: 3 local football teams play Friday: a closer look
- Impact[0] NLP[0.43]: Bristol Virginia Fire Department responds to Thanksgiving house fire - Impact[0] NLP[0.43]: Bristol Virginia Fire Department responds to Thanksgiving house fire
- Impact[0] NLP[0.0]: 3 local football teams play Friday: a closer look
- Impact[0] NLP[0.0]: 7 women facing contraband-related charges in Washington County, Tennessee, authorities say
- Impact[0] NLP[0.0]: Wreaths Across America coming up in December in Johnson City - Impact[0] NLP[0.0]: Wreaths Across America coming up in December in Johnson City
- Impact[0] NLP[0.0]: Missing Virginia high school coach charged with child pornography, police say
- Impact[0] NLP[0.0]: Tennessee inmate who killed Chattanooga State student declines to choose execution method - Impact[0] NLP[0.0]: Tennessee inmate who killed Chattanooga State student declines to choose execution method
- Impact[0] NLP[0.0]: Rye Cove advances to state semifinals, Eastside and Greeneville's seasons come to an end - Impact[0] NLP[0.0]: Missing Virginia high school coach charged with child pornography, police say
- Impact[0] NLP[0.0]: Eastside and Rye Cove gear up for region championship rematch - Impact[0] NLP[0.0]: Eastside and Rye Cove gear up for region championship rematch
- Impact[0] NLP[0.0]: Rye Cove advances to state semifinals, Eastside and Greeneville's seasons come to an end
- Impact[0] NLP[0.0]: Bristol, Tennessee police investigating double homicide, victims identified - Impact[0] NLP[0.0]: Bristol, Tennessee police investigating double homicide, victims identified
- Impact[0] NLP[0.0]: Bristol, Virginia church serves holiday spirit with annual Thanksgiving meal for community - Impact[0] NLP[0.0]: Bristol, Virginia church serves holiday spirit with annual Thanksgiving meal for community
- Impact[0] NLP[0.0]: Coaches weigh in ahead of postseason weekend - Impact[0] NLP[0.0]: Coaches weigh in ahead of postseason weekend
- Impact[0] NLP[0.0]: Tennessee's 7th District race draws national spotlight as election nears - Impact[0] NLP[0.0]: Tennessee's 7th District race draws national spotlight as election nears
- Impact[0] NLP[0.0]: Stateline Sports Reporters Podcast: Ridgeview vs Union Preview
- Impact[0] NLP[0.0]: Spotless giraffe Kipekee passes away at Brights Zoo - Impact[0] NLP[0.0]: Spotless giraffe Kipekee passes away at Brights Zoo
- Impact[0] NLP[0.0]: Lee County Sheriff's Office investigating after body found in St. Charles - Impact[0] NLP[0.0]: Stateline Sports Reporters Podcast: Ridgeview vs Union Preview
- Impact[0] NLP[0.0]: UPDATE: Virginia State Police searching for Union head football coach Travis Turner
- Impact[0] NLP[0.0]: High School Basketball Scores and Highlights: November 28, 2025 - Impact[0] NLP[0.0]: High School Basketball Scores and Highlights: November 28, 2025
- Impact[87] NLP[0.0]: Webster Springs community mourns West Virginia National Guard member killed in attack - Impact[87] NLP[0.0]: Webster Springs community mourns West Virginia National Guard member killed in attack
- Impact[0] NLP[0.0]: Is giftflation blowing up your holiday budget? Heres how to fight it. - Impact[0] NLP[0.0]: Is giftflation blowing up your holiday budget? Heres how to fight it.

View File

@@ -197,7 +197,7 @@ input[type=text] {
<a href="map.html" class="w3-button w3-black">Cam Map</a> <a href="map.html" class="w3-button w3-black">Cam Map</a>
<a href="db.html" class="w3-button w3-black">WU obs</a> <a href="db.html" class="w3-button w3-black">WU obs</a>
<a href="5min.html" class="w3-button w3-black">5m ASOS obs</a> <a href="5min.html" class="w3-button w3-black">5m ASOS obs</a>
<a href="today.txt" class="w3-button w3-black">CoCoRaHS Remarks</a> <a href="today.html" class="w3-button w3-black">CoCoRaHS Remarks</a>
<a id = "buffer" href="outage.html?buffer=true" class="w3-button w3-black">Outage Map w/ Outside Counties</a> <a id = "buffer" href="outage.html?buffer=true" class="w3-button w3-black">Outage Map w/ Outside Counties</a>
<a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a> <a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a>
<a style="font-size:24px">Power Outage Tracker</a> <a style="font-size:24px">Power Outage Tracker</a>

View File

@@ -197,7 +197,7 @@ input[type=text] {
<a href="map.html" class="w3-button w3-black">Cam Map</a> <a href="map.html" class="w3-button w3-black">Cam Map</a>
<a href="db.html" class="w3-button w3-black">WU obs</a> <a href="db.html" class="w3-button w3-black">WU obs</a>
<a href="5min.html" class="w3-button w3-black">5m ASOS obs</a> <a href="5min.html" class="w3-button w3-black">5m ASOS obs</a>
<a href="today.txt" class="w3-button w3-black">CoCoRaHS Remarks</a> <a href="today.html" class="w3-button w3-black">CoCoRaHS Remarks</a>
<a id = "buffer" href="outage.html?buffer=true" class="w3-button w3-black">Outage Map w/ Outside Counties</a> <a id = "buffer" href="outage.html?buffer=true" class="w3-button w3-black">Outage Map w/ Outside Counties</a>
<a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a> <a href="https://docs.google.com/forms/d/1-2rTBkNyyBVe08G1vN1hcSOEOvvLUcS1Vs2SmmaudlU" class="w3-button w3-black" target="_blank">Questions? Comments?</a>
<a style="font-size:24px">Power Outage Tracker</a> <a style="font-size:24px">Power Outage Tracker</a>

31
today.html Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Cocorahs Weather Data - 11/29/2025</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; }
tr:nth-child(even) { background-color: #f9f9f9; }
</style>
</head>
<body>
<h1>Cocorahs Weather Data - 11/29/2025</h1>
<table>
<thead>
<tr>
<th>Date/Time of Ob (Z)</th>
<th>Station Number</th>
<th>Station Name</th>
<th>New Precip</th>
<th>New Snow</th>
<th>Snow Depth</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>

View File

@@ -1,60 +1 @@
Date/Time of Ob (Z) Station Number Station Name New Precip New Snow Snow Depth Comments Date/Time of Ob (Z) Station Number Station Name New Precip New Snow Snow Depth Comments
2025-11-28 10:36 AM WV-NC-3 Runa 0.1 W T T T Flurries at dark. With skiff on ground this am . 25 degrees.
2025-11-28 10:51 AM WV-LN-3 Branchland 5.6 ESE T NA NA flurries
2025-11-28 02:12 PM WV-MA-10 Rivesville 1.7 N NA NA NA
2025-11-28 11:21 AM WV-LW-6 Weston 5.1 NW T T NA
2025-11-28 11:42 AM WV-DD-2 West Union 8.2 NE T NA NA Snow
2025-11-28 11:36 AM WV-MA-14 Fairmont 0.8 SSW 0.01 0.2 NA Cloudy and 25. Roads are sheets of ice.
2025-11-28 11:38 AM WV-HN-9 New Cumberland 2.7 NNE 0.02 0.2 0.0
2025-11-28 11:57 AM WV-PR-20 Bruceton Mills 2.8 S T 0.3 T
2025-11-28 12:01 PM WV-PT-10 Hurricane 1.6 SSW T T 0.0 Mostly cloudy 30F at ob. A few flurries late yesterday afternoon and again over the past hour.
2025-11-28 12:01 PM WV-KN-43 South Charleston 1.6 ENE T NA NA
2025-11-28 12:07 PM WV-PC-4 Cass 3.7 SW 0.01 0.0 NA Partly cloudy and breezy and cold with a skiff of snow.
2025-11-28 12:08 PM WV-MG-16 Morgantown 5.9 SW 0.02 0.8 0.5 On/off snow showers during period. There was a light daytime dusting of snow. Snow accumulated overnight.
2025-11-28 12:08 PM WV-BY-16 Bunker Hill 1.5 SW 0.00 0.0 0.0
2025-11-28 12:09 PM WV-KN-55 Charleston 4.0 SSE 0.00 0.0 NA
2025-11-28 12:10 PM WV-OH-6 Valley Grove 3.5 NNE 0.00 0.0 NA Currently 27.7F. High 33.8 at 10:08 am; low 27.5 at 1 am; bar 30.09 r
2025-11-28 12:21 PM WV-RT-4 Harrisville 3.9 NNE 0.00 0.0 0.0
2025-11-28 12:29 PM WV-RT-2 Pennsboro 1.2 ESE 0.00 0.0 NA
2025-11-28 12:34 PM WV-HS-11 Lost Creek 1.3 NW T T NA Cloudy 29°F flurries and light snow showers off and on all day yesterday but nothing in the tube to actually measure
2025-11-28 12:41 PM WV-RL-16 Mount Hope 3.6 WSW 0.00 0.0 NA
2025-11-28 12:43 PM WV-JC-3 Ripley 5.8 S T T NA
2025-11-28 12:45 PM WV-KN-53 South Charleston 0.3 SSW T 0.0 0.0 Maximum temperature: 39.0F minimum temperature: 30.0F
2025-11-28 12:52 PM WV-KN-33 Charleston 2.6 W T 0.0 0.0
2025-11-28 01:01 PM WV-PR-11 Thomas 7.4 N 0.04 0.5 0.5 High 26.9 Low 20.1 Wind gust 17.5
2025-11-28 01:10 PM WV-NC-4 Craigsville 0.6 NE 0.01 T T Temperature 23F degrees Snow Flurries
2025-11-28 01:30 PM WV-HY-2 Rig 0.4 NW T T T
2025-11-28 01:52 PM WV-GL-4 Glenville 5.9 W 0.00 0.0 NA
2025-11-28 01:53 PM WV-WD-7 Williamstown 0.4 WNW T T T
2025-11-28 01:57 PM WV-MC-11 Princeton 0.3 NNW 0.00 0.0 NA
2025-11-28 01:57 PM WV-DD-1 Center Point 2.2 NNW T T T
2025-11-28 01:59 PM WV-HM-2 Slanesville 2.1 SE T NA NA
2025-11-28 02:12 PM WV-BN-4 Danville 1.8 WSW 0.00 0.0 NA
2025-11-28 05:43 PM WV-CY-3 Clay 0.2 WSW 0.00 0.0 NA
2025-11-28 12:30 PM WV-JF-15 Harpers Ferry 12.8 SSW T T NA Almost imperceptible light flurries around 10:30 PM. Wouldn't be sure except multiple people independently noted the flakes in the air.
2025-11-28 12:51 PM WV-MR-3 Union 2.4 SSE 0.00 0.0 NA
2025-11-28 12:33 PM WV-KN-50 Charleston 5.9 SE 0.00 0.0 NA
2025-11-28 12:41 PM WV-BY-13 Martinsburg 2.9 SE 0.00 0.0 NA
2025-11-28 01:04 PM WV-PR-14 Bruceton Mills 9.3 SE T 0.5 0.5
2025-11-28 02:22 PM WV-WT-1 New Martinsville 6.5 E T T T Prior Day: Temperatures max 35°, min 27°. Sunshine 0.5 kWh/m2/Day. Humidity 73%. Wind,9, gust 40, SW.
Cloudy yesterday. A few snowflakes, 27° this morning.
2025-11-28 01:14 PM WV-CB-17 Huntington 1.7 ESE 0.00 0.0 0.0
2025-11-28 01:19 PM WV-WN-5 Fort Gay 3.3 ENE 0.00 0.0 NA
2025-11-28 01:28 PM WV-DD-4 Auburn 8.3 ENE 0.00 0.0 NA
2025-11-28 02:44 PM WV-GL-3 Auburn 4.0 E T NA NA
2025-11-28 03:24 PM WV-WD-22 Walker 6.4 NE 0.00 0.0 NA Standing water had ice over and snow flakes falling but no signs that it will accumulate.
2025-11-28 03:52 PM WV-CB-23 Huntington 3.4 ESE 0.00 0.0 NA
2025-11-28 05:38 PM WV-PT-14 Buffalo 0.7 NE 0.00 0.0 0.0 29F at ob
2025-11-28 01:22 PM WV-HN-10 Chester 3.0 SSE 0.01 NA NA Melted snow
2025-11-28 01:52 PM WV-KN-5 St. Albans 1.0 WNW 0.00 0.0 0.0 Clearing skies this morning.
2025-11-28 04:03 PM WV-KN-1 Alum Creek 3.0 E T T 0.0
2025-11-28 12:04 PM OH-MS-7 Albany 3.0 SSE 0.00 0.0 0.0 ~90% overcast, wsw 1.6mph, 27°F, 1040.5 mb, rh 55%, dp 13°F
2025-11-28 12:12 PM OH-AT-21 Athens 4.6 ESE 0.00 0.0 NA
2025-11-28 12:44 PM OH-AT-9 Glouster 3.6 SW T NA NA
2025-11-28 12:59 PM OH-WS-16 Coolville 5.3 N 0.00 0.0 NA
2025-11-28 01:21 PM OH-AT-6 Albany 4.1 NW 0.00 0.0 NA
2025-11-28 01:57 PM OH-AT-1 Athens 1.3 N 0.00 0.0 NA
2025-11-28 03:33 PM OH-MG-3 Glouster 5.7 NE T T NA
2025-11-28 04:59 PM OH-AT-3 Stewart 4.6 NNE 0.00 0.0 NA
2025-11-28 05:15 PM OH-WS-14 Marietta 3.5 NNW 0.00 0.0 NA
2025-11-28 01:00 PM KY-CT-4 Grayson 4.8 NNE 0.00 0.0 0.0 8:00 OBS: partly cloudy, wind WNW 0-3 mph, temp 29F, dewpt 22F, RH 74%, bar 30.31” & rising (+0.04” last 3 hrs)