gouravgujariya commited on
Commit
5a381fc
·
1 Parent(s): 003c512

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -8,6 +8,14 @@ st.title("Web Scraper with Streamlit")
8
  # User input for the URL
9
  url = st.text_input("Enter the URL of the website you want to scrape:")
10
 
 
 
 
 
 
 
 
 
11
  if st.button("Scrape Data"):
12
  if not url:
13
  st.error("Please enter a valid URL.")
@@ -36,9 +44,3 @@ if st.button("Scrape Data"):
36
  else:
37
  st.error("Failed to retrieve the web page. Status code:", response.status_code)
38
 
39
- # Function to create a download link for a JSON file
40
- def get_binary_file_downloader_html(json_data, title):
41
- json_data = json_data.encode()
42
- b64 = base64.b64encode(json_data).decode()
43
- href = f'<a href="data:file/json;base64,{b64}" download="{title}">Download JSON</a>'
44
- return href
 
8
  # User input for the URL
9
  url = st.text_input("Enter the URL of the website you want to scrape:")
10
 
11
+
12
+ # Function to create a download link for a JSON file
13
+ def get_binary_file_downloader_html(json_data, title):
14
+ json_data = json_data.encode()
15
+ b64 = base64.b64encode(json_data).decode()
16
+ href = f'<a href="data:file/json;base64,{b64}" download="{title}">Download JSON</a>'
17
+ return href
18
+
19
  if st.button("Scrape Data"):
20
  if not url:
21
  st.error("Please enter a valid URL.")
 
44
  else:
45
  st.error("Failed to retrieve the web page. Status code:", response.status_code)
46