This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevecentral.py
68 lines (62 loc) · 2.15 KB
/
evecentral.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
import urllib2
from xml.etree import ElementTree
def get_buys(item_id,region):
try:
response = urllib2.urlopen("http://api.eve-central.com/api/quicklook?typeid="+str(item_id)+"®ionlimit="+str(region))
tree = ElementTree.parse(response)
ql = tree.find('quicklook')
if ql == None:
return -1
buy_orders = ql.find('buy_orders')
except urllib2.HTTPError:
return(-1)
return(buy_orders)
def get_sys_buys(item_id,system):
try:
response = urllib2.urlopen("http://api.eve-central.com/api/quicklook?typeid="+str(item_id)+"&usesystem="+str(system))
tree = ElementTree.parse(response)
ql = tree.find('quicklook')
if ql == None:
return -1
buy_orders = ql.find('buy_orders')
except urllib2.HTTPError:
return(-1)
return(buy_orders)
def get_sys_sells(item_id,system):
try:
response = urllib2.urlopen("http://api.eve-central.com/api/quicklook?typeid="+str(item_id)+"&usesystem="+str(system))
tree = ElementTree.parse(response)
ql = tree.find('quicklook')
if ql == None:
return -1
sell_orders = ql.find('sell_orders')
except urllib2.HTTPError:
return(-1)
return(sell_orders)
def find_sys_price(item_id,system):
buy_orders = get_sys_buys(item_id,system)
if buy_orders == -1:
return 0
best = 0
for order in buy_orders:
if float(order.find('price').text) > best:
best = float(order.find('price').text)
return best
def find_sys_sell(item_id,system):
sell_orders = get_sys_sells(item_id,system)
if sell_orders == -1 or len(sell_orders) == 0:
return 0
best = float(sell_orders[0].find('price').text)
for order in sell_orders:
if float(order.find('price').text) < best:
best = float(order.find('price').text)
return best
def find_best_price(item_id,region):
buy_orders = get_buys(item_id,region)
if buy_orders == -1:
return 0
best = 0
for order in buy_orders:
if float(order.find('price').text) > best:
best = float(order.find('price').text)
return best