rajuesaa commited on
Commit
49d3b3e
·
1 Parent(s): c4805ce

Fix: Add URL validation and protocol check

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -136,14 +136,17 @@ with tab1:
136
  if input_type == "URL":
137
  source_url = st.text_input("Enter Content URL", placeholder="https://example.com/blog-post")
138
  if st.button("Fetch Content"):
139
- with st.spinner("Extracting content..."):
140
- extracted_data = ContentExtractor.from_url(source_url)
141
- if "error" in extracted_data:
142
- st.error(f"Failed to fetch content: {extracted_data['error']}")
143
- extracted_data = None
144
- else:
145
- st.session_state.extracted_content = extracted_data
146
- st.success("Content fetched successfully!")
 
 
 
147
 
148
  elif input_type == "RSS Feed":
149
  rss_url = st.text_input("Enter RSS Feed URL", placeholder="https://example.com/feed")
 
136
  if input_type == "URL":
137
  source_url = st.text_input("Enter Content URL", placeholder="https://example.com/blog-post")
138
  if st.button("Fetch Content"):
139
+ if not source_url or "://" not in source_url:
140
+ st.error("Please enter a valid URL (including https://)")
141
+ else:
142
+ with st.spinner("Extracting content..."):
143
+ extracted_data = ContentExtractor.from_url(source_url)
144
+ if "error" in extracted_data:
145
+ st.error(f"Failed to fetch content: {extracted_data['error']}")
146
+ extracted_data = None
147
+ else:
148
+ st.session_state.extracted_content = extracted_data
149
+ st.success("Content fetched successfully!")
150
 
151
  elif input_type == "RSS Feed":
152
  rss_url = st.text_input("Enter RSS Feed URL", placeholder="https://example.com/feed")