eshan6704 commited on
Commit
5f3429c
·
verified ·
1 Parent(s): 5429761

Create bhavcopy_html.py

Browse files
Files changed (1) hide show
  1. bhavcopy_html.py +19 -0
bhavcopy_html.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+
3
+ def fetch_bhavcopy_html(date_str):
4
+ """
5
+ Use existing nse_bhavcopy function to fetch Bhavcopy and return HTML.
6
+ """
7
+ # Validate date format
8
+ try:
9
+ datetime.datetime.strptime(date_str, "%d-%m-%Y")
10
+ except ValueError:
11
+ return "<h3>Invalid date format. Please use DD-MM-YYYY.</h3>"
12
+
13
+ # Fetch data using your existing function
14
+ try:
15
+ df = nse_bhavcopy(date_str)
16
+ # Convert to HTML and wrap scrollable
17
+ return wrap(df)
18
+ except Exception:
19
+ return f"<h3>No Bhavcopy found for {date_str}. Please check the date.</h3>"