Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import websocket
- import threading
- import time
- import json
- import requests
- import os
- import sys
- header = [
- "Accept-Encoding: gzip, deflate, br",
- "Accept-Language: uk-UA,uk; q = 0.9,ru; q = 0.8,en - US; q = 0.7,en; q = 0.6",
- "Cache-Control: no-cache",
- "Connection: Upgrade",
- "Pragma: no-cache",
- "Upgrade: websocket",
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36",
- ]
- ws = websocket.create_connection("wss://gamdomtr.com/socket.io/?EIO=3&transport=websocket",
- origin="https://gamdomtr.com",
- host="gamdomtr.com")
- print(ws.recv())
- ws.send("40/p2p,")
- def ping():
- while True:
- ws.send("2")
- # print(ws.recv())
- time.sleep(4)
- def shop():
- while True:
- items_list = []
- items = ws.recv()
- if items != "3":
- try:
- items = json.loads(items[7::])
- if items[0] == 'initialize':
- for i in items[1]['listings']:
- if i['item_count'] == 1:
- name = i['items'][0]['market_name']
- price = i['total_price']
- item = {
- 'name': name,
- 'price': round(price/1000, 2)
- }
- items_list.append(item)
- with open('items.json', 'w') as data:
- json.dump(items_list, data)
- elif items[0] == "newListing":
- if items[1]['item_count'] == 1:
- name = items[1]['items'][0]['market_name']
- price = items[1]['total_price']
- item = {
- 'name': name,
- 'price': round(price/1000, 2)
- }
- print(item)
- with open('items.json', 'r') as data:
- items_list = json.load(data)
- items_list.append(item)
- with open('items.json', 'w') as data:
- json.dump(items_list, data)
- elif items[0] == "removeListing":
- if items[1]['item_count'] == 1:
- with open('items.json', 'r') as data:
- itemss = json.load(data)
- for i in itemss:
- if i['name'] == items[1]['items'][0]['market_name']:
- itemss.remove(i)
- with open('items.json', 'w') as data:
- json.dump(itemss, data)
- except json.decoder.JSONDecodeError:
- pass
- def parse():
- while True:
- print('##############################')
- try:
- with open('items.json', 'r') as data:
- items = json.load(data)
- for i in items:
- if 'profit' not in i:
- req = json.loads(requests.get('http://steamcommunity.com/market/'
- 'priceoverview/?appid=730'
- '¤cy=1&market_hash_name='+ i['name']).text)
- st = req['lowest_price'][1::]
- i['steam'] = st
- i['profit'] = round((1-(i['price'] / (float(i['steam']) * 0.87)))*100, 2)
- with open('items.json', 'w') as data:
- json.dump(items, data)
- print(i)
- time.sleep(5)
- except:
- pass
- def exit():
- input()
- os.remove('items.json')
- sys.exit()
- threading_ping = threading.Thread(target=ping)
- threading_shop = threading.Thread(target=shop)
- threading_parse = threading.Thread(target=parse)
- threading_exit = threading.Thread(target=exit)
- threading_ping.start()
- threading_exit.start()
- threading_shop.start()
- threading_parse.start()
- threading_ping.join()
- threading_exit.join()
- threading_shop.join()
- threading_parse.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement