Created
May 17, 2023 01:32
-
-
Save alphasecio/d7c6b59b35d1839fc66f67dc119d780a to your computer and use it in GitHub Desktop.
Load URL using LangChain UnstructuredURLLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import validators, streamlit as st | |
from langchain.document_loaders import UnstructuredURLLoader | |
url = st.text_input("Enter URL") | |
if st.button("Load"): | |
try: | |
if not url.strip(): | |
st.error("Please enter a URL") | |
elif not validators.url(url): | |
st.error("Invalid URL. Please enter a valid URL") | |
else: | |
loader = UnstructuredURLLoader(urls=[url]) | |
data = loader.load() | |
st.success(data) | |
except Exception as e: | |
st.error(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment