|
|
@@ -0,0 +1,65 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+
|
|
|
+from xml.etree import ElementTree
|
|
|
+
|
|
|
+import oursql
|
|
|
+import requests
|
|
|
+
|
|
|
+conn = oursql.connect(db='eve', user='eve', passwd='eve')
|
|
|
+rs = requests.session()
|
|
|
+
|
|
|
+def get_systemid(name):
|
|
|
+ with conn as c:
|
|
|
+ c.execute('SELECT solarSystemID FROM mapSolarSystems WHERE solarSystemName LIKE ?',
|
|
|
+ (name,))
|
|
|
+ return c.fetchone()[0]
|
|
|
+
|
|
|
+def iter_items():
|
|
|
+ with conn as c:
|
|
|
+ # metaGroupID's:
|
|
|
+ # NULL or 1: Tech I
|
|
|
+ # 2: Tech II
|
|
|
+ # 3: storyline
|
|
|
+ # 4: faction
|
|
|
+ # 5: officer
|
|
|
+ # 6: deadspace
|
|
|
+ # 14: Tech III
|
|
|
+ c.execute('''
|
|
|
+ SELECT invTypes.typeID, typeName FROM invTypes
|
|
|
+ LEFT JOIN invMetaTypes ON invMetaTypes.typeID = invTypes.typeID
|
|
|
+ WHERE marketGroupID IS NOT NULL AND metaGroupID != 5
|
|
|
+ ''')
|
|
|
+ while True:
|
|
|
+ r = c.fetchone()
|
|
|
+ if r is None:
|
|
|
+ break
|
|
|
+ yield r
|
|
|
+
|
|
|
+def get_prices(typeid, systemid):
|
|
|
+ url = 'http://api.eve-central.com/api/marketstat?typeid=%d&usesystem=%d' % (typeid, systemid)
|
|
|
+ response = rs.get(url, stream=True)
|
|
|
+ xml = ElementTree.fromstring(response.text)
|
|
|
+ parent = xml.find('marketstat').find('type')
|
|
|
+
|
|
|
+ buy = parent.findall('buy')[0].find('max')
|
|
|
+ bid = float(buy.text)
|
|
|
+
|
|
|
+ sell = parent.find('sell').find('min')
|
|
|
+ ask = float(sell.text)
|
|
|
+
|
|
|
+ volume = parent.find('all').find('volume')
|
|
|
+ vol = int(volume.text)
|
|
|
+
|
|
|
+ return bid, ask, vol
|
|
|
+
|
|
|
+def main():
|
|
|
+ for system in ['amarr', 'rens', 'dodixie', 'hek']:
|
|
|
+ systemid = get_systemid(system)
|
|
|
+ with open(system, 'w') as f:
|
|
|
+ for typeid, name in iter_items():
|
|
|
+ bid, ask, vol = get_prices(typeid, systemid)
|
|
|
+ score = (ask - bid) * vol
|
|
|
+ f.write('%f\t%f\t%f\t%d\t%s\n' % (score, ask, bid, vol, name))
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ main()
|