-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscriptify_gui.py
More file actions
48 lines (39 loc) · 1.76 KB
/
subscriptify_gui.py
File metadata and controls
48 lines (39 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import requests
from bs4 import BeautifulSoup
import spacy
import streamlit as st
def get_website_text(url):
try:
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
return soup.get_text(separator=' ')
except requests.RequestException as e:
return f"Error fetching website: {e}"
def analyze_subscription(text):
nlp = spacy.load("en_core_web_sm")
doc = nlp(text.lower())
subscription_keywords = {"subscribe", "membership", "premium", "paywall", "pricing", "unlimited access", "trial"}
found_keywords = {token.text for token in doc if token.text in subscription_keywords}
if found_keywords:
if "free trial" in text.lower() or "limited access" in text.lower():
return "Freemium Model: Some content is free, but full access requires a subscription."
return "Paid Subscription Required: This website seems to require a membership."
return "Free Access: This website appears to be free to use."
def main():
st.title("Subscriptify - Website Subscription Checker")
st.write("Enter a website URL to check its subscription model.")
url = st.text_input("Website URL:")
if st.button("Check Subscription"):
if url.strip():
text = get_website_text(url.strip())
if text and not text.startswith("Error"):
result = analyze_subscription(text)
st.success(result)
else:
st.error("Unable to fetch website content. The website may block scraping.")
else:
st.warning("Please enter a valid URL.")
if __name__ == "__main__":
main()