Advertisement
Ixurano

Untitled

Dec 1st, 2021
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. #hämtar sajten
  2. def getData(pageNr):
  3.     req = requests.get(f'https://store.steampowered.com/search/?specials=1&page={pageNr}')
  4.     page = req.text
  5.     soup = bs(page, 'html.parser')
  6.  
  7. def weeklyRun():
  8.     '''Function to run each week to append the list with updated values'''
  9.     #For loop to append rating into the list
  10.     for i in range(0, len(review)):
  11.         d['SpelNamn'].append(allGameNames[i])
  12.         d['Rating'].append(rating_transform(ratingOrg[i]))
  13.         d['Reviews'].append(reViews[i])
  14.         d['Rabatt'].append(allDiscounts[i])
  15.         d['Pris'].append(allPrice[i])
  16.         d['OrdinariePris'].append(orgPrice[i])
  17.         d['Utgivningsår'].append(allReleaseYear[i])
  18.         d['Win'].append(isWinComp[i])
  19.         d['Lin'].append(isLinuxComp[i])
  20.         d['OSX'].append(isMacComp[i])
  21.         d['Tid'].append(date[i])
  22.  
  23. for i in range(1,5):
  24.     getData(i)
  25.     weeklyRun()
  26.  
  27. # tries to update if file exist otherwise creates it
  28. try:
  29.     file = open("./statistic.csv")
  30.     print("updating file")
  31.     df = pd.DataFrame.from_dict(d)
  32.     df.to_csv(r'statistic.csv', mode='a', index = False, encoding='utf-8')
  33. except:
  34.     print("creating file")
  35.     df = pd.DataFrame.from_dict(d)
  36.     df.to_csv(r'statistic.csv', index = False, encoding='utf-8')
  37. finally:
  38.     file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement