File size: 2,760 Bytes
dee81af
 
18fb2d0
 
dee81af
 
 
 
18fb2d0
 
 
 
 
 
 
 
 
 
 
3ff5449
4d9a7ab
18fb2d0
 
3ff5449
18fb2d0
 
 
 
 
 
 
3ff5449
 
e6c03c9
 
1ef0484
7514d3f
4ba8de1
7514d3f
 
 
1ea7fc9
1ef0484
 
e6c03c9
 
dee81af
e6c03c9
 
 
dee81af
e6c03c9
 
 
 
 
dee81af
e6c03c9
dee81af
e6c03c9
 
 
dee81af
e6c03c9
1d04a42
e6c03c9
fc70bd6
1d04a42
8c0e2df
1d04a42
c9f3fd9
e6c03c9
8c0e2df
ef7e473
3ff5449
e6c03c9
 
 
fc70bd6
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import streamlit as st
from transformers import pipeline
import requests
from bs4 import BeautifulSoup

# Initialize a text generation pipeline
generator = pipeline('text-generation', model='dbmdz/german-gpt2')

# Define a function to fetch trending news related to a specific niche
def fetch_trending_news(niche):
    url = f"https://www.google.com/search?q={niche}+news&tbs=qdr:d"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
    response = requests.get(url, headers=headers)
    soup = BeautifulSoup(response.content, "html.parser")
    news_items = soup.find_all("div", class_="BNeawe vvjwJb AP7Wnd")
    trending_news = [item.text for item in news_items[:5]]  # Extract the top 5 news items
    return trending_news

# Define the pages
def page_trending_niche():
    st.title("What is trending in my niche?")
    st.image('Robot.png', use_column_width=True)
    
    niche = st.text_input('Enter your niche', 'German clinics')
    st.write(f"Trending news in {niche}:")
    
    trending_news = fetch_trending_news(niche)
    for idx, news_item in enumerate(trending_news, start=1):
        st.write(f"{idx}. {news_item}")



# Define the pages
def page_social_media_generator():
    
    # Using st.columns to create a two-column layout
    col1, col2 = st.columns([3, 1])
    with col1:
        st.title("German Medical Content Manager")
    with col2:
        st.image('Content_Creation_Pic.png', use_column_width=True)

    
    input_topic = st.text_input('Enter a medical topic', 'Type 1 Diabetes')
    st.write(f"Creating social media content for: {input_topic}")

    def generate_content(topic):
        generated_text = generator(f"Letzte Nachrichten über {topic}:", max_length=50, num_return_sequences=1)
        return generated_text[0]['generated_text']

    if st.button('Generate Social Media Post'):
        with st.spinner('Generating...'):
            post_content = generate_content(input_topic)
            st.success('Generated Content:')
            st.write(post_content)

    st.write('Generated social media posts will appear here after clicking the "Generate" button.')

def page_test():
    st.title('Test Page')
    st.write('This is a test page with a test name.')

# Setup the sidebar with page selection
st.sidebar.title("Anne's Current Projects :star2:")

page = st.sidebar.selectbox(
    'What project do you like to see first?',
    ('trending_niche', 'Social Media Content Generator', 'Test Page'))


# Display the selected page
if page == 'trending_niche':
    page_trending_niche()
elif page == 'Social Media Content Generator':
    page_social_media_generator()
elif page == 'Test Page':
    page_test()