-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
152 lines (125 loc) · 4.71 KB
/
main.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
146
147
148
149
150
151
152
__author__ = 'SHADOW'
from functions import *
import io
import pycurl
import requests
import stem.process
import concurrent.futures
from stem.util import term
import json
import time
from urllib.parse import unquote
import socks # SocksiPy module
import socket
import urllib
import stem.process
from stem.util import term
import time
import concurrent.futures
import logging
from random import randint
logger = logging.getLogger()
SOCKS_PORT = 7000
# socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
# socket.socket = socks.socksocket
urls = ["http://steamcommunity.com/market/listings/730/AK-47%20%7C%20Elite%20Build%20%28Well-Worn%29",
"http://steamcommunity.com/market/listings/730/AK-47%20%7C%20Elite%20Build%20%28Field-Tested%29",
"http://steamcommunity.com/market/listings/730/P2000%20%7C%20Amber%20Fade%20%28Field-Tested%29",
"http://steamcommunity.com/market/listings/730/USP-S%20%7C%20Torque%20%28Field-Tested%29",
"http://steamcommunity.com/market/listings/730/Dual%20Berettas%20%7C%20Cobalt%20Quartz%20%28Field-Tested%29"
]
'''def buy(url):
if url == "https://www.atagar.com/echo.php" or url == "http://canihazip.com/s":
return requests.get(url).text
tail = '/render?start=0&count=5¤cy=3&language=english&format=json'
try:
return requests.get(url + tail).json()
except:
print("Unable to reach", url)'''
def curl(url):
if url == "https://www.atagar.com/echo.php" or url == "http://canihazip.com/s":
u = url
else:
u = url + '/render?start=0&count=5¤cy=3&language=english&format=json'
output = io.BytesIO()
query = pycurl.Curl()
query.setopt(pycurl.URL, u)
query.setopt(pycurl.PROXY, 'localhost')
query.setopt(pycurl.PROXYPORT, SOCKS_PORT)
query.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
query.setopt(pycurl.WRITEFUNCTION, output.write)
try:
query.perform()
return output.getvalue().decode('utf-8')
except pycurl.error as exc:
print("Unable to reach %s (%s)" % (url, exc))
def print_bootstrap_lines(line):
if "Bootstrapped " in line:
print(term.format(line, term.Color.BLUE))
print(term.format("Starting Tor:\n", term.Attr.BOLD))
tor_process = stem.process.launch_tor_with_config(
tor_cmd=r'C:\Users\SHADOW\Desktop\New folder\Tor Browser\Browser\TorBrowser\Tor\tor.exe',
config={
'SocksPort': str(SOCKS_PORT),
'ExitNodes': '{ru}',
},
init_msg_handler=print_bootstrap_lines,
)
def main_function(x, y):
duplicate_check = []
session = sessionid()
while True:
try:
a = curl(x)
# print(a)
if a == "null":
print("Null")
b = json.loads(a)
res = []
form_data = {}
for item, key in b['listinginfo'].items():
try:
res.append([item, key['converted_price']])
form_data[item] = {"sessionid": session,
"currency": 3,
"subtotal": int(key['converted_price']) - int(key['converted_fee']),
"fee": int(key['converted_fee']),
"total": int(key['converted_price']),
"quantity": 1
}
except KeyError:
res.append("SOLD!")
print(y, '-->', unquote(x.split("/render")[0]).replace(' ', ''), res)
# print(form_data)
# print(' ')
for price in res:
if price != 'SOLD!':
if price[1] <= int(y):
print('GOT ONE')
if price[0] not in duplicate_check:
buy(x, price[0], form_data[price[0]])
duplicate_check.append(price[0])
# print(res)
except BaseException as e:
logger.error('ERR ' + str(e))
continue
sleep(randint(10, 20))
def f():
prices_list = []
for item in urls:
prices_list.append(get_buy_price(item))
print(term.format(curl("https://www.atagar.com/echo.php"), term.Color.YELLOW))
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
executor.map(main_function, urls, prices_list)
# print(requests.get("http://canihazip.com/s").text)
# one_by_one()
# f()
# print(curl("http://canihazip.com/s"))
# print(curl("http://steamcommunity.com/market/listings/730/AK-47%20%7C%20Elite%20Build%20%28Well-Worn%29"))
'''
while True:
f()
time.sleep(10)'''
if __name__ == '__main__':
f()
tor_process.kill() # stops tor'''