I have a problem with buttons

Hello!

I have a “little” problem with buttons… I wanted to create an app to scrape prices from one page. At this moment app looks like this:

(its in Polish for school purposes).

First need to fill name of game and select platform then I hit “Szukaj” → “Search” and this app scrape info from a page and with BeautifulSoup parses to the list of dicts and then show a table like this. Then when I press button “link_X” I would like to be moved to another subpage where is the price comparation from many different shops, after that I would like to scrape this page and show this prices in a chart…

The problem is when I hit “link” button this page refreshes loosing all data and variables

Is there any way to avoid this refreshing? Thank you so much for help💖

Most likely no, but you can avoid the data loss by using session state.

No good… then I’ll rewrite backend a bit, I hope it will be a bit easier :slight_smile: thank you so much for quick answer :sparkling_heart:

It shouldn’t be that much of a rewrite. Wherever you have something like this:

my_data = fetch_my_data()

change it by this:

st.session_state.my_data = fetch_my_data()

Then instead of this:

st.write(my_data)

do this:

st.write(st.session_state.my_data)

Oh I’ll try it :slight_smile: thank you for your help!