Spaces:
Runtime error
Runtime error
Fix: Add URL validation and protocol check
Browse files
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 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
extracted_data =
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
| 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")
|