dvaz commited on
Commit
d8d92bc
1 Parent(s): 406d287

Upload 16_Pricerunner.py

Browse files
Files changed (1) hide show
  1. pages/16_Pricerunner.py +19 -3
pages/16_Pricerunner.py CHANGED
@@ -1,10 +1,13 @@
1
  import requests
2
  import streamlit as st
3
-
4
-
5
 
6
  st.set_page_config('Price',menu_items={'About': "This is an *extremely* cool app!"})
7
 
 
 
 
8
 
9
  menu=['Find price']
10
  ch=st.sidebar.selectbox('Menu',menu)
@@ -34,7 +37,7 @@ if 'Find price' in ch:
34
  r2=requests.get('https://www.pricerunner.dk/public/productlistings/v3/pl/2-'+id+'/dk/filter')
35
  x2=r2.json()
36
  x3=x2['filteredOfferList']['merchantOffers'][0]['offers'][0]['url']
37
-
38
 
39
  st.header(name)
40
  st.write(des)
@@ -42,5 +45,18 @@ if 'Find price' in ch:
42
  st.write('Link to buy:')
43
  st.write('https://www.pricerunner.dk'+ x3)
44
 
 
 
 
45
  st.write('---')
46
 
 
 
 
 
 
 
 
 
 
 
 
1
  import requests
2
  import streamlit as st
3
+ import sqlite3
4
+ import pandas as pd
5
 
6
  st.set_page_config('Price',menu_items={'About': "This is an *extremely* cool app!"})
7
 
8
+ con = sqlite3.connect("mydb.db")
9
+ cur = con.cursor()
10
+
11
 
12
  menu=['Find price']
13
  ch=st.sidebar.selectbox('Menu',menu)
 
37
  r2=requests.get('https://www.pricerunner.dk/public/productlistings/v3/pl/2-'+id+'/dk/filter')
38
  x2=r2.json()
39
  x3=x2['filteredOfferList']['merchantOffers'][0]['offers'][0]['url']
40
+ link=('https://www.pricerunner.dk'+ x3)
41
 
42
  st.header(name)
43
  st.write(des)
 
45
  st.write('Link to buy:')
46
  st.write('https://www.pricerunner.dk'+ x3)
47
 
48
+ cur.execute("insert into proucts values(?,?,?,?)", (name,low,des,link))
49
+ con.commit()
50
+
51
  st.write('---')
52
 
53
+ df = pd.read_sql('SELECT * FROM proucts ', con)
54
+ h = df.to_csv(sep=',')
55
+ c = st.download_button("Download csv file",h,'price.csv','text/csv',)
56
+
57
+ if c :
58
+ cur.execute("DELETE from proucts ")
59
+ con.commit()
60
+ st.warning('Database is empty now again,try with new search again')
61
+
62
+