-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteam.py
145 lines (134 loc) · 5.55 KB
/
steam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import json
import os
import requests
import settings
from fake_useragent import UserAgent
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time
from sys import platform
from progress.spinner import Spinner
from progress.bar import Bar
ua = UserAgent()
cookies = {}
convert = 0
total_page = 0
def clear(func):
def wrapper():
if platform == "linux" or platform == "linux2":
os.system('clear')
elif platform == "win32":
os.system('cls')
func()
return wrapper
def reg():
options = webdriver.ChromeOptions()
options.add_argument(f"user-agent={ua.random}")
options.add_argument('--headless')
options.add_argument("--disable-infobars")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
window = str()
driver.get(settings.buff_reg)
time.sleep(1)
driver.find_element(By.XPATH, '/html/body/div[1]/div/div[3]/ul/li/a').click()
time.sleep(1)
driver.find_element(By.XPATH, '//*[@id="j_login_other"]').click()
time.sleep(1)
for i in driver.window_handles:
if i == driver.current_window_handle:
window += i
else:
driver.switch_to.window(i)
time.sleep(1)
if platform == "linux" or platform == "linux2":
os.system('clear')
elif platform == "win32":
os.system('cls')
print('=' * 50)
name = str(input('>Никнейм Steam :'))
driver.find_element(By.XPATH, '//*[@id="steamAccountName"]').send_keys(name)
password = str(input('>Пароль Steam :'))
driver.find_element(By.XPATH, '//*[@id="steamPassword"]').send_keys(password)
driver.find_element(By.XPATH, '//*[@id="imageLogin"]').click()
guard_s = str(input('>Steam Guard :')).upper()
driver.find_element(By.XPATH, '//*[@id="twofactorcode_entry"]').send_keys(guard_s)
driver.find_element(By.XPATH, '//*[@id="login_twofactorauth_buttonset_entercode"]/div[1]').click()
# driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[2]/a').click()
driver.switch_to.window(window)
time.sleep(3)
driver.refresh()
time.sleep(1)
driver_cookies = driver.get_cookies()
driver.close()
driver.quit()
for cookie in driver_cookies:
cookies[cookie['name']] = cookie['value']
with open('cookies.json', 'w') as file:
json.dump(cookies, file)
file.close()
steam()
@clear
def steam():
balance = float(requests.get('https://buff.163.com/api/asset/get_brief_asset/', cookies=cookies).json()['data']['alipay_amount'])*convert
try:
for i in range(1, total_page):
time.sleep(0.5)
r = requests.get(f'https://buff.163.com/api/market/goods?game=csgo&page_num={i}', cookies=cookies).json()['data']
for item in r['items']:
name = item['name']
buff_price = float(item['sell_min_price']) * convert
steam_price = float(item['goods_info']['steam_price'])
sell_num = int(item['sell_num'])
steam_link = item['steam_market_url']
buff_link = f'https://buff.163.com/goods/{item["id"]}?from=market#tab=selling'
if shop == 1:
if 69 > (value := (buff_price / steam_price) * 100) > 30 and sell_num >= 230 and buff_price <= balance:
print(f'{name}\nSell : {sell_num}\n{(100-value):.2f} %\n>BUFF : {buff_price:.2f} $\nBuff Link : {buff_link}\n>STEAM : {steam_price:.2f} $\nSteam Link : {steam_link}')
print('-'*20)
else:
continue
elif shop == 2:
if (value := (buff_price / steam_price) * 100) > 103 and sell_num >= 165:
print(f'{name}\nSell : {sell_num}\n{(value-100):.2f} %\n>BUFF : {buff_price:.2f} $\nBuff Link : {buff_link}\n>STEAM : {steam_price:.2f} $\nSteam Link : {steam_link}')
print('-'*20)
else:
continue
except:
print('EXIT')
@clear
def cs_money():
offset = 0
batch_size = 60
try:
while True:
for i in range(offset, offset + batch_size, 60):
response = requests.get(f'https://inventories.cs.money/5.0/load_bots_inventory/730?buyBonus=30&isStore=true&limit=60&maxPrice=100000&minPrice=1&offset={i}&sort=botFirst&withStack=true', headers={'user-agent': f'{ua.random}'}).json()['items']
offset += batch_size
for item in response:
overprice = item['overprice']
if overprice < 80 and overprice is not None:
price_steam = item['price']
#steam = requests.get(f'https://steamcommunity.com/market/listings/730/{item["fullName"]}')
print(item['fullName'], price_steam, overprice)
else:
continue
except:
print('EXIT')
if __name__ == '__main__':
print('[1] BUFF -> STEAM\n[2] STEAM -> BUFF\n[3] CS MONEY')
shop = int(input('>>'))
r = requests.get(settings.buff_json).json()['data']
total_page = r['total_page']
cost = requests.get(settings.money).json()['rates']
convert = cost['USD']
if shop == 3:
cs_money()
else:
try:
cookies = json.load(open("cookies.json", "r"))
steam()
except FileNotFoundError:
reg()