Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
|
5 |
+
def fetch_page_title(url):
|
6 |
+
"""
|
7 |
+
Fetches the title of the given URL.
|
8 |
+
|
9 |
+
Args:
|
10 |
+
url (str): The URL of the webpage.
|
11 |
+
|
12 |
+
Returns:
|
13 |
+
str: The title of the webpage or an error message.
|
14 |
+
"""
|
15 |
+
try:
|
16 |
+
response = requests.get(url)
|
17 |
+
if response.status_code == 200:
|
18 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
19 |
+
title = soup.title.string if soup.title else 'No title found'
|
20 |
+
return title
|
21 |
+
else:
|
22 |
+
return f"Error: Received status code {response.status_code}"
|
23 |
+
except Exception as e:
|
24 |
+
return f"An error occurred: {e}"
|
25 |
+
|
26 |
+
def main():
|
27 |
+
"""
|
28 |
+
Main function to run the Streamlit application.
|
29 |
+
"""
|
30 |
+
st.title("OSINT Tool")
|
31 |
+
st.write("Enter a URL to fetch its title:")
|
32 |
+
|
33 |
+
url = st.text_input("URL")
|
34 |
+
if url:
|
35 |
+
title = fetch_page_title(url)
|
36 |
+
st.write(f"Title: {title}")
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
main()
|