Guest User

Untitled

a guest
Jun 10th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. import pandas as pd
  2. from pandas import json_normalize
  3.  
  4. count = 0
  5. url_base = 'https://store.steampowered.com/appreviews/393380?json=1&cursor='
  6. #36734
  7.  
  8. #first pass
  9. url = urllib.request.urlopen("https://store.steampowered.com/appreviews/393380?json=1&cursor=*")
  10. data = json.loads(url.read().decode())
  11. next_cursor = data['cursor']
  12. df1 = json_normalize(data['reviews'])
  13. count += 20
  14. print(next_cursor)
  15. print(count)
  16.  
  17.  
  18. #next pass
  19. url_temp = url_base+next_cursor
  20. url = urllib.request.urlopen(url_temp)
  21. data = json.loads(url.read().decode())
  22. next_cursor = data['cursor']
  23. df2 = json_normalize(data['reviews'])
  24. df1 = pd.concat([df1, df2])
  25. count += 20
  26. print(next_cursor)
  27. print(count)
  28.  
  29. #next pass
  30. url_temp = url_base+next_cursor
  31. url = urllib.request.urlopen(url_temp)
  32. data = json.loads(url.read().decode())
  33. next_cursor = data['cursor']
  34. df2 = json_normalize(data['reviews'])
  35. df1 = pd.concat([df1, df2])
  36. count += 20
  37. print(next_cursor)
  38. print(count)
  39.  
  40. #next pass
  41. url_temp = url_base+next_cursor
  42. url = urllib.request.urlopen(url_temp)
  43. data = json.loads(url.read().decode())
  44. next_cursor = data['cursor']
  45. df2 = json_normalize(data['reviews'])
  46. df1 = pd.concat([df1, df2])
  47. count += 20
  48. print(next_cursor)
  49. print(count)
  50.  
  51. #next pass
  52. url_temp = url_base+next_cursor
  53. url = urllib.request.urlopen(url_temp)
  54. data = json.loads(url.read().decode())
  55. next_cursor = data['cursor']
  56. df2 = json_normalize(data['reviews'])
  57. df1 = pd.concat([df1, df2])
  58. count += 20
  59. print(next_cursor)
  60. print(count)
  61.  
  62. #next pass
  63. url_temp = url_base+next_cursor
  64. url = urllib.request.urlopen(url_temp)
  65. data = json.loads(url.read().decode())
  66. next_cursor = data['cursor']
  67. df2 = json_normalize(data['reviews'])
  68. df1 = pd.concat([df1, df2])
  69. count += 20
  70. print(next_cursor)
  71. print(count)
  72.  
  73. #next pass
  74. url_temp = url_base+next_cursor
  75. url = urllib.request.urlopen(url_temp)
  76. data = json.loads(url.read().decode())
  77. next_cursor = data['cursor']
  78. df2 = json_normalize(data['reviews'])
  79. df1 = pd.concat([df1, df2])
  80. count += 20
  81. print(next_cursor)
  82. print(count)
  83.  
  84. #send df to csv
  85. df1.to_csv('file_name.csv')
Add Comment
Please, Sign In to add comment