forked from foxpcteam/AI-Marketer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSEM.py
47 lines (36 loc) · 1.87 KB
/
SEM.py
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
import streamlit as st
from ecommercetools import advertising
from util import p_title
import pandas as pd
def SEM(nav):
if nav == '⌨Google AdWord Generator':
st.text('')
p_title('⌨Google AdWord Generator')
st.text('')
st.markdown(":white_check_mark:Create a list of keywords for Google AdWords")
example_product_names = 'phone case , stainless steel phone case'
product_names = st.text_input('Input the product names in list use comma to seperate the product',example_product_names)
product_names = product_names.split(',')
example_keywords_prepend = 'buy,best,cheap,reduced'
keywords_prepend = st.text_input('Input the words that you want to add before the product names',example_keywords_prepend)
keywords_prepend = keywords_prepend.split(',')
example_keywords_append = 'for sale,price,promotion'
keywords_append = st.text_input('Input the words that you want to add before the product names',example_keywords_append)
keywords_append = keywords_append.split(',')
example_campaign_name = 'phone case'
campaign_name = st.text_input('Input the campaign name',example_campaign_name)
if st.button('Submit'):
keywords = advertising.generate_ad_keywords(product_names, keywords_prepend, keywords_append,campaign_name)
keywords=keywords.astype(str)
st.dataframe(keywords)
@st.cache
def convert_df(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv().encode('utf-8')
csv = convert_df(pd.DataFrame(keywords))
st.download_button(
label="Download data as CSV",
data=csv,
file_name='SEM.csv',
mime='text/csv',
)