Skip to content

Instantly share code, notes, and snippets.

@alphasecio
Created May 17, 2023 01:32
Show Gist options
  • Save alphasecio/d7c6b59b35d1839fc66f67dc119d780a to your computer and use it in GitHub Desktop.
Save alphasecio/d7c6b59b35d1839fc66f67dc119d780a to your computer and use it in GitHub Desktop.
Load URL using LangChain UnstructuredURLLoader
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