Okay, I have another question
I was trying to use your program on a different web page
of the same website.. but I could not generate the output..
This is the url of the new page :
"https://www.cocorahs.org/ViewData/ListDailyPrecipReports.aspx"
NOW, this new web page has checkboxes..
I think that's where I'm messing up..
I did a view page source and looked up the html tag names but it seems
I am missing something very conceptual.. I am wondering what it might be !!
This is my code. What changes should I make to it ?
Thank You !!
import requests
from bs4 import BeautifulSoup
from requests_html import HTMLSession
import pandas as pd
from io import StringIO
from datetime import datetime
session = requests.Session()
response = session.get('https://www.cocorahs.org/ViewData/ListDailyPrecipReports.aspx')
soup = BeautifulSoup(response.content, "html.parser")
view_state = soup.find("input", {"name": "__VIEWSTATE", "value": True})["value"]
view_state_generator = soup.find("input", {"name": "__VIEWSTATEGENERATOR", "value": True})["value"]
event_validation = soup.find("input", {"name": "__EVENTVALIDATION", "value": True})["value"]
response = session.post('https://www.cocorahs.org/ViewData/ListDailyPrecipReports.aspx', data={
"__EVENTTARGET": "",
"__EVENTARGUMENT": "",
"__LASTFOCUS": "",
"VAM_Group": "",
"__VIEWSTATE": view_state,
"VAM_JSE": "1",
"__VIEWSTATEGENERATOR": view_state_generator,
"__EVENTVALIDATION": event_validation,
"obsSwitcher:ddlObsUnits": "usunits",
"frmPrecipReportSearch:ucStationTextFieldsFilter:tbTextFieldValue": "FL-BV-163",
"frmPrecipReportSearch:ucStationTextFieldsFilter:cblTextFieldsToSearch:0": "checked",
"frmPrecipReportSearch:ucStationTextFieldsFilter:cblTextFieldsToSearch:1": "",
"frmPrecipReportSearch:ucStateCountyFilter:ddlCountry": "allcountries",
"frmPrecipReportSearch:ucDateRangeFilter:dcStartDate:di": "6/13/2025",
"frmPrecipReportSearch:ucDateRangeFilter:dcStartDate:hfDate": "2025-06-13",
"frmPrecipReportSearch:ucDateRangeFilter:dcEndDate:di": "6/16/2025",
"frmPrecipReportSearch:ucDateRangeFilter:dcEndDate:hfDate": "2025-06-16",
"frmPrecipReportSearch:ddlPrecipField": "GaugeCatch",
"frmPrecipReportSearch:ucPrecipValueFilter:ddlOperator": "LessEqual",
"frmPrecipReportSearch:ucPrecipValueFilter:tbPrecipValue:tbPrecip": "0.15",
"frmPrecipReportSearch:btnSearch": "Search",
})
table = BeautifulSoup(response.content, "html.parser").find("table", id="ucReportList_ReportGrid")
if table is None:
raise RuntimeError("table#ucReportList_ReportGrid not found")
df = pd.read_html(StringIO(str(table)))[0]
print(df)