Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #hämtar sajten
- def getData(pageNr):
- req = requests.get(f'https://store.steampowered.com/search/?specials=1&page={pageNr}')
- page = req.text
- soup = bs(page, 'html.parser')
- def weeklyRun():
- '''Function to run each week to append the list with updated values'''
- #For loop to append rating into the list
- for i in range(0, len(review)):
- d['SpelNamn'].append(allGameNames[i])
- d['Rating'].append(rating_transform(ratingOrg[i]))
- d['Reviews'].append(reViews[i])
- d['Rabatt'].append(allDiscounts[i])
- d['Pris'].append(allPrice[i])
- d['OrdinariePris'].append(orgPrice[i])
- d['Utgivningsår'].append(allReleaseYear[i])
- d['Win'].append(isWinComp[i])
- d['Lin'].append(isLinuxComp[i])
- d['OSX'].append(isMacComp[i])
- d['Tid'].append(date[i])
- for i in range(1,5):
- getData(i)
- weeklyRun()
- # tries to update if file exist otherwise creates it
- try:
- file = open("./statistic.csv")
- print("updating file")
- df = pd.DataFrame.from_dict(d)
- df.to_csv(r'statistic.csv', mode='a', index = False, encoding='utf-8')
- except:
- print("creating file")
- df = pd.DataFrame.from_dict(d)
- df.to_csv(r'statistic.csv', index = False, encoding='utf-8')
- finally:
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement