Skip to content

Commit cd902fd

Browse files
committed
Fixed mistake
Fixed mistake made by reformatting the file. Added some comments. Increased time between cases to lower chance of errors. updated readme
1 parent 4dacd84 commit cd902fd

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Prices/price_grabber.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def add_date(file):
3131

3232

3333
def cases(out):
34-
print('Starting Case Compiler (Approx 8 mins):')
34+
""" Creates a list of all cases, their price and every skin inside the case and add it to the file given (out) """
35+
print('Starting Case Compiler (Approx 9 mins):')
3536
time_ = time.time()
3637
cases = []
3738
r = requests.get('https://csgostash.com/containers/skin-cases')
@@ -41,7 +42,7 @@ def cases(out):
4142
if '<div class="well result-box nomargin">' in c:
4243
price = c.split('<p class="nomargin">')[1].split('</p>')[0].replace('\\xc2\\xa3', '').replace('$', '')
4344
case_name = c.split('<h4>')[1].split('</h4>')[0].replace('amp;', '')
44-
cases.append(ast.literal_eval((f'["{case_name}","{price}"]')))
45+
cases.append(ast.literal_eval(f'["{case_name}","{price}"]'))
4546
print(cases)
4647

4748
for case in cases:
@@ -55,24 +56,24 @@ def cases(out):
5556
'{"type":"html","value":"Contains one of the following:"}')[1].split(f',"name":"{case[0]}"')[0].split(
5657
',"tradable"')[0])
5758
dic = '[' + dic[1:len(dic)]
58-
dic = ast.literal_eval(dic)
59+
dic = ast.literal_eval(dic) # Creates a list of all the items in the case
5960
dic = dic[0:len(dic) - 3]
6061
for i in range(0, len(dic)):
6162
gun = (dic[i]['value']).replace('\\u2665', '')
6263
rareness = rarity[dic[i]['color']]
63-
items.append([gun, rareness])
64+
items.append([gun, rareness]) # Adds each run and its rarity to the list
6465
print(f'[Case_Compiler] ~ {case[0]}, {items_web}, took {time.time() - start_time} seconds')
65-
except IndexError:
66-
print('Ignoring ' + case[0])
66+
except IndexError as e:
67+
print('Ignoring ' + case[0], e)
6768
items_web.close()
68-
time.sleep(15)
69+
time.sleep(17)
6970
f.write(case[0] + ':::' + case[1] + ':::' + str(items) + '\n')
7071
print(f'Case Compiler Took - {(time.time() - time_) / 60} mins')
7172
f.close()
7273

7374

7475
def csgo_stash_ids(file):
75-
print('Starting the CsgoStash ID compiler (Approx 7 minutes):')
76+
print('Starting the CsgoStash ID compiler (Approx 19 minutes):')
7677
i = 0
7778
names = []
7879
end = []
@@ -167,7 +168,7 @@ def csgostash_price(ids, skin):
167168

168169
def skin_prices(ids, inp, out):
169170
total_time = time.time()
170-
print('Getting all case skin prices (Approx 9 mins):')
171+
print('Getting all case skin prices (Approx 7 mins):')
171172
skins = []
172173
ifile = open(str(inp), 'r')
173174
ofile = open(str(out), 'w+')
@@ -214,10 +215,10 @@ def item_case_search(files):
214215
price_file = files[1]
215216
stash_ids = files[2]
216217
processes = []
217-
p = multiprocessing.Process(target=cases, args=case_file, )
218+
p = multiprocessing.Process(target=cases, args=[case_file])
218219
p.start()
219220
processes.append(p)
220-
p = multiprocessing.Process(target=csgo_stash_ids, args=stash_ids, )
221+
p = multiprocessing.Process(target=csgo_stash_ids, args=[stash_ids])
221222
p.start()
222223
processes.append(p)
223224
for p in processes:

readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
## CSGO Case Data Analysis (Currently without knives/gloves)
22

3-
Works out average profit per case (Currently only uses gun skin prices), the code only currently accuratly works for GBP but can easily changed in the main.py file (So without changes the code will crash or be unaccurate unless you live in UK).
4-
The code takes a while to run as Steam has a limit on requests so it compiles data from CSGOStash as well as SteamMarket, but only uses steam market prices.
3+
Works out average profit per case (Currently only uses gun skin prices), the code only currently accurately works for GBP but can easily be changed in the main.py file (So without changes the code will crash or be inaccurate unless you live in UK).
4+
The code takes a while to run as Steam has a limit on requests, so it compiles data from CSGOStash as well as SteamMarket, but only uses steam market prices.
55
The code should have no need to be changed when a new case gets released, unless they do something odd.
66

77
## How It Calculates Values
88

9-
Gets average price of each skin of each rarity and stattrack of each case according to the rarity of each, then calculates cost of opening each case. Gets average cost and minus's average outcome of each case.
9+
Gets average price of each skin of each rarity and stat-track of each case according to the rarity of each, then calculates cost of opening each case. Gets average cost and minus's average outcome of each case.
1010

1111
## Instructions
1212

1313
- Install python 3
1414
- Install requests module - `pip install requests`
15-
- It can take about 17 mins to compile all the data it needs
15+
- It can take about 27 mins to compile all the data it needs
1616
- Run main.py
1717
- Program outputs the result in the results.txt file located in /current
1818

@@ -24,8 +24,8 @@ Gets average price of each skin of each rarity and stattrack of each case accord
2424
But the code should work fine
2525

2626

27-
## Example Results (10/05/2022)
28-
27+
## Example Results:
28+
####(10/05/2022)
2929
```
3030
CS:GO Weapon Case 3 ~ -0.49065092733333415
3131
Shadow Case ~ -0.5353895642857143

0 commit comments

Comments
 (0)