Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
|
| 6 |
-
# Configure
|
| 7 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 8 |
OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"
|
| 9 |
|
| 10 |
def scrape_website(url):
|
| 11 |
-
"""Scrapes
|
| 12 |
if not url.startswith("http"):
|
| 13 |
url = f"https://{url}"
|
| 14 |
|
|
@@ -18,40 +20,45 @@ def scrape_website(url):
|
|
| 18 |
soup = BeautifulSoup(response.content, "html.parser")
|
| 19 |
|
| 20 |
content = []
|
| 21 |
-
|
| 22 |
meta_description = soup.find("meta", {"name": "description"})
|
| 23 |
if meta_description and meta_description.get("content"):
|
| 24 |
content.append(meta_description["content"])
|
| 25 |
|
|
|
|
| 26 |
for tag in ['h1', 'h2', 'p']:
|
| 27 |
elements = soup.find_all(tag)
|
| 28 |
content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])
|
| 29 |
-
|
| 30 |
return " ".join(content[:1500])
|
| 31 |
except Exception as e:
|
| 32 |
st.error(f"Error scraping website: {str(e)}")
|
| 33 |
return None
|
| 34 |
|
| 35 |
-
def
|
| 36 |
-
"""Generates a
|
| 37 |
-
prompt = f"""
|
| 38 |
-
{
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
headers = {
|
| 47 |
-
"Authorization": f"Bearer {
|
| 48 |
"Content-Type": "application/json"
|
| 49 |
}
|
| 50 |
|
| 51 |
data = {
|
| 52 |
"model": "gpt-4", # Using OpenAI GPT-4 model
|
| 53 |
"messages": [
|
| 54 |
-
{"role": "system", "content": "You are
|
| 55 |
{"role": "user", "content": prompt}
|
| 56 |
],
|
| 57 |
"temperature": 0.7,
|
|
@@ -67,45 +74,41 @@ Format your response in clear markdown with actionable insights and a profession
|
|
| 67 |
return None
|
| 68 |
|
| 69 |
# Streamlit UI
|
| 70 |
-
st.
|
| 71 |
-
st.
|
| 72 |
-
st.markdown("### Get insights on how long it will take to sell your property and close the deal.")
|
| 73 |
|
| 74 |
-
input_method = st.radio("Choose input method:", ["Enter
|
| 75 |
|
| 76 |
-
if input_method == "Enter
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
asking_price = st.text_input("Asking Price (optional)")
|
| 82 |
|
| 83 |
-
if st.button("
|
| 84 |
-
if not all([
|
| 85 |
st.error("Please fill in all required fields marked with *")
|
| 86 |
else:
|
| 87 |
-
with st.spinner("
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
st.markdown(analysis)
|
| 98 |
-
|
| 99 |
else:
|
| 100 |
-
website_url = st.text_input("Enter
|
| 101 |
|
| 102 |
-
if st.button("
|
| 103 |
if not website_url:
|
| 104 |
st.error("Please enter a valid website URL")
|
| 105 |
else:
|
| 106 |
-
with st.spinner("Extracting
|
| 107 |
website_content = scrape_website(website_url)
|
| 108 |
if website_content:
|
| 109 |
-
|
| 110 |
-
if
|
| 111 |
-
st.markdown(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
st.set_page_config(page_title="Video Marketing Plan Generator", layout="wide")
|
| 3 |
+
|
| 4 |
import requests
|
| 5 |
import os
|
| 6 |
from bs4 import BeautifulSoup
|
| 7 |
|
| 8 |
+
# Configure OpenAI API (using OPENAI_API_KEY)
|
| 9 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 10 |
OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"
|
| 11 |
|
| 12 |
def scrape_website(url):
|
| 13 |
+
"""Scrapes business content from the given website URL."""
|
| 14 |
if not url.startswith("http"):
|
| 15 |
url = f"https://{url}"
|
| 16 |
|
|
|
|
| 20 |
soup = BeautifulSoup(response.content, "html.parser")
|
| 21 |
|
| 22 |
content = []
|
| 23 |
+
# Extract meta description if available
|
| 24 |
meta_description = soup.find("meta", {"name": "description"})
|
| 25 |
if meta_description and meta_description.get("content"):
|
| 26 |
content.append(meta_description["content"])
|
| 27 |
|
| 28 |
+
# Extract text from h1, h2, and p tags
|
| 29 |
for tag in ['h1', 'h2', 'p']:
|
| 30 |
elements = soup.find_all(tag)
|
| 31 |
content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])
|
| 32 |
+
|
| 33 |
return " ".join(content[:1500])
|
| 34 |
except Exception as e:
|
| 35 |
st.error(f"Error scraping website: {str(e)}")
|
| 36 |
return None
|
| 37 |
|
| 38 |
+
def generate_video_marketing_plan(business_info):
|
| 39 |
+
"""Generates a comprehensive video marketing plan using OpenAI GPT-4."""
|
| 40 |
+
prompt = f"""As a leading video marketing strategist specializing in conversion optimization, create a comprehensive video marketing plan for the following business:
|
| 41 |
+
{business_info}
|
| 42 |
+
|
| 43 |
+
Your plan should include:
|
| 44 |
+
1. **Core Strategy:** Identify 3 unique angles or approaches that differentiate this business’s video content and showcase its unique value proposition.
|
| 45 |
+
2. **Funnel Architecture:** Provide detailed video content ideas for each stage of the funnel: Awareness, Consideration, Conversion, and Post-Purchase.
|
| 46 |
+
3. **Content Blueprints:** For the top 3 video concepts, include a content outline, key messaging points, attention-grabbing hooks, call-to-action strategy, ideal length/format, and platform-specific tips.
|
| 47 |
+
4. **Production Guidelines:** Recommend visual styles, music/sound design, text overlay strategies, and thumbnail design principles.
|
| 48 |
+
5. **Distribution Strategy:** Suggest primary platforms, posting frequency, cross-platform repurposing, hashtag/keyword recommendations, and community engagement tactics.
|
| 49 |
+
6. **Measurement Framework:** Define KPIs, engagement metrics, conversion tracking, and A/B testing recommendations to evaluate performance.
|
| 50 |
+
|
| 51 |
+
Format your response in clear markdown with headers and bullet points, and explain the strategic reasoning behind each recommendation."""
|
| 52 |
|
| 53 |
headers = {
|
| 54 |
+
"Authorization": f"Bearer {OPENAI_API_KEY}",
|
| 55 |
"Content-Type": "application/json"
|
| 56 |
}
|
| 57 |
|
| 58 |
data = {
|
| 59 |
"model": "gpt-4", # Using OpenAI GPT-4 model
|
| 60 |
"messages": [
|
| 61 |
+
{"role": "system", "content": "You are a top-tier video marketing strategist with years of experience developing conversion-optimized video funnels."},
|
| 62 |
{"role": "user", "content": prompt}
|
| 63 |
],
|
| 64 |
"temperature": 0.7,
|
|
|
|
| 74 |
return None
|
| 75 |
|
| 76 |
# Streamlit UI
|
| 77 |
+
st.title("🎥 Video Marketing Plan Generator")
|
| 78 |
+
st.markdown("### Generate a comprehensive video marketing plan for your business.")
|
|
|
|
| 79 |
|
| 80 |
+
input_method = st.radio("Choose input method:", ["Enter business details manually", "Use website URL"])
|
| 81 |
|
| 82 |
+
if input_method == "Enter business details manually":
|
| 83 |
+
business_name = st.text_input("Business Name*")
|
| 84 |
+
business_description = st.text_area("What does your company do?*", help="Describe your products/services and what makes you unique.")
|
| 85 |
+
ideal_client = st.text_area("Ideal Client Profile*", help="Include demographics, challenges they face, and why they need your solution.")
|
| 86 |
+
marketing_goals = st.text_area("Marketing Goals (optional)", help="Describe your primary marketing objectives, target metrics, and any specific goals.")
|
|
|
|
| 87 |
|
| 88 |
+
if st.button("Generate Marketing Plan"):
|
| 89 |
+
if not all([business_name, business_description, ideal_client]):
|
| 90 |
st.error("Please fill in all required fields marked with *")
|
| 91 |
else:
|
| 92 |
+
with st.spinner("Creating your custom video marketing plan..."):
|
| 93 |
+
business_info = f"""
|
| 94 |
+
Business Name: {business_name}
|
| 95 |
+
Business Description: {business_description}
|
| 96 |
+
Ideal Client Profile: {ideal_client}
|
| 97 |
+
Marketing Goals: {marketing_goals if marketing_goals else 'Not provided'}
|
| 98 |
+
"""
|
| 99 |
+
plan = generate_video_marketing_plan(business_info)
|
| 100 |
+
if plan:
|
| 101 |
+
st.markdown(plan)
|
|
|
|
|
|
|
| 102 |
else:
|
| 103 |
+
website_url = st.text_input("Enter your business website URL*", placeholder="e.g., www.example.com")
|
| 104 |
|
| 105 |
+
if st.button("Generate Marketing Plan"):
|
| 106 |
if not website_url:
|
| 107 |
st.error("Please enter a valid website URL")
|
| 108 |
else:
|
| 109 |
+
with st.spinner("Extracting business details and generating your video marketing plan..."):
|
| 110 |
website_content = scrape_website(website_url)
|
| 111 |
if website_content:
|
| 112 |
+
plan = generate_video_marketing_plan(website_content)
|
| 113 |
+
if plan:
|
| 114 |
+
st.markdown(plan)
|