Skip to content

Commit

Permalink
Add feature from issue #12
Browse files Browse the repository at this point in the history
  • Loading branch information
sinchanashetty11 committed Oct 20, 2023
1 parent c945a0b commit 8f57e2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 158 deletions.
26 changes: 14 additions & 12 deletions slash_user_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def highlight_row(dataframe):

st.write("ShopSync is an android application, website and a command line tool that scrapes the most popular e-commerce websites to get the best deals on the searched items across these websites.")
product = st.text_input('Enter the product item name')
website = st.selectbox('Select the website',('Amazon', 'Walmart', 'Ebay', 'BestBuy', 'Target', 'Costco', 'All'))
website = st.selectbox('Select the website',('All','Walmart', 'Amazon', 'Ebay', 'BestBuy', 'Target', 'Costco', 'All'))

website_dict = {
'Amazon':'az',
'Walmart':'wm',
'Amazon':'az',
'Ebay':'eb',
'BestBuy':'bb',
'Target':'tg',
Expand Down Expand Up @@ -194,7 +194,7 @@ def add_http_if_not_present(url):
else:
st.error('Sorry!, there is no other website with same product')

if 'dataframe' in st.session_state:
if 'dataframe' in st.session_state and isinstance(st.session_state.dataframe, pd.DataFrame):

st.markdown("<h1 style='text-align: center; color: #1DC5A9;'>RESULT</h1>", unsafe_allow_html=True)

Expand All @@ -206,16 +206,18 @@ def add_http_if_not_present(url):

st.write('<span style="font-size: 24px;">Add for favorites</span>', unsafe_allow_html=True)

selected_index = st.selectbox("Select an index to get the corresponding row:", [None] + list(range(len(st.session_state.dataframe))))
if selected_index is not None:
fav =pd.DataFrame([st.session_state.dataframe.iloc[selected_index]])
if 'fav' in st.session_state:
st.session_state.fav = pd.concat([st.session_state.fav, fav], axis=0).drop_duplicates()
st.dataframe(st.session_state.fav.style, column_config={"Link": st.column_config.LinkColumn("URL to website"), "Button": st.column_config.LinkColumn("Add to fav")},)
if st.session_state.dataframe is not None:
selected_index = st.selectbox("Select an index to get the corresponding row:", [None] + list(range(len(st.session_state.dataframe))))

else:
st.session_state.fav = fav.copy()
st.dataframe(fav.style, column_config={"Link": st.column_config.LinkColumn("URL to website"), "Button": st.column_config.LinkColumn("Add to fav")},)
if selected_index is not None:
fav =pd.DataFrame([st.session_state.dataframe.iloc[selected_index]])
if 'fav' in st.session_state:
st.session_state.fav = pd.concat([st.session_state.fav, fav], axis=0).drop_duplicates()
st.dataframe(st.session_state.fav.style, column_config={"Link": st.column_config.LinkColumn("URL to website"), "Button": st.column_config.LinkColumn("Add to fav")},)

else:
st.session_state.fav = fav.copy()
st.dataframe(fav.style, column_config={"Link": st.column_config.LinkColumn("URL to website"), "Button": st.column_config.LinkColumn("Add to fav")},)


# Add footer to UI
Expand Down
7 changes: 4 additions & 3 deletions src/main_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def search_items_API(
}

scrapers = []

if site == 'az' or site == 'all':
scrapers.append('amazon')
if site == 'wm' or site == 'all':
scrapers.append('walmart')
if site == 'az' or site == 'all':
scrapers.append('amazon')
#if site == 'wm' or site == 'all':
# scrapers.append('walmart')
if site == 'tg' or site == 'all':
scrapers.append('target')
if site == 'cc' or site == 'all':
Expand Down
143 changes: 0 additions & 143 deletions src/scraper.py

This file was deleted.

0 comments on commit 8f57e2e

Please sign in to comment.