vgprice.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env python
  2. # Game: Revenue:
  3. # Pokemon 296.98
  4. # Yu-Gi-Oh! 27.53
  5. # Yo-kai Watch 12.916
  6. # Beyblade 0.97
  7. # Digimon 0.24
  8. import requests
  9. import re
  10. def digimon():
  11. digimon_games = requests.get("https://wikimon.net/api.php?action=query&formatversion=2&prop=revisions&rvprop=content&rvslots=*& titles=List_of_Video_Games&format=json").json()
  12. digimon_games = digimon_games["query"]["pages"][0]["revisions"][0]["slots"]["main"]["content"]
  13. #print(digimon_games)
  14. # good regek <i><a.*?href=".*?".*?>(.*?)</a></i>
  15. find = re.findall('\* \[\[(.*?)\]\]', digimon_games)
  16. games = []
  17. for game in find:
  18. if "|" in game:
  19. game = game.split("|")[1]
  20. elif "(Game)" in game:
  21. game = ' '.join(game.split(" ")[:-1])
  22. elif ":" in game:
  23. game = game.replace(":", "%3A")
  24. games.append(game)
  25. return games
  26. def beyblade():
  27. beyblade_games = requests.get("https://bw.vern.cc/beyblade/wiki/Category:Video_Games").text
  28. find = re.findall('<li><a.*?href=".*?".*?>(.*?)</a></li>', beyblade_games)[:-1]
  29. games = []
  30. for game in find:
  31. compiled = re.compile(re.escape(" (video game)"), re.IGNORECASE)
  32. res = compiled.sub("", game)
  33. res = res.replace(" (game)", "")
  34. res = res.replace(" (Switch game)", "")
  35. games.append(res)
  36. return games
  37. def pricecalc(find):
  38. price = 0
  39. for game in find:
  40. print(game)
  41. data = requests.get(f"https://www.vgchartz.com/games/games.php?name={game}&keyword=&console=&region=All&developer=&publisher=& goty_year=&genre=&boxart=Both&banner=Both&ownership=Both&showmultiplat=No&results=50&order=Sales&showtotalsales=0&showtotalsales=1& showpublisher=0&showvgchartzscore=0&shownasales=0&showdeveloper=0&showcriticscore=0&showpalsales=0&showreleasedate=0&showuserscore=0& showjapansales=0&showlastupdate=0&showothersales=0&showshipped=0").text
  42. try:
  43. results = re.findall('<th colspan="3" align="left" style="color:white;">Results: (.+?)</th>', data)[0]
  44. if results == "(0)":
  45. print("Could not find price :(")
  46. else:
  47. prices = re.findall('<td align="center">(.+?)</td>', data)[0]
  48. if "m" in prices:
  49. price += float(prices.split("m")[0])
  50. print(prices)
  51. print(price)
  52. except:
  53. print("uh oh")
  54. print(price)
  55. def yu_gi_oh():
  56. data = requests.get("https://www.vgchartz.com/games/games.php?name=yu-gi-oh&keyword=&console=&region=All&developer=&publisher=&goty_year=&genre=&boxart=Both&banner=Both&ownership=Both&showmultiplat=No&results=200&order=Sales&showtotalsales=0&showtotalsales=1&showpublisher=0&showvgchartzscore=0&shownasales=0&showdeveloper=0&showcriticscore=0&showpalsales=0&showreleasedate=0&showuserscore=0&showjapansales=0&showlastupdate=0&showothersales=0&showshipped=0").text
  57. prices = re.findall('<td align="center">(.+?)</td>', data)
  58. price = 0
  59. for game in prices:
  60. if "m" in game:
  61. price += float(game.split("m")[0])
  62. print(game)
  63. print(price)
  64. print(price)
  65. yu_gi_oh()