Exporting information

Pazleysox

Member
I am trying to write a script that will search the mall for specific items, and return the prices to an exported file that I can view. How would I do that? I understand how to get the mall_search to do what I want, but how can I export the information that I'm getting?

-Paz
 

icon315

Member
Try...
PHP:
string [item] prices;
foreach i in $items[A, B, C]{
prices[i] = mall_price(i);
print(i);
print(mall_price(i));
}
map_to_file(prices,"prices.txt");
 

Pazleysox

Member
Sweet, this totally rocks!! Once i got past my n00bish tendencies, and figured out what you wrote for me, it works awesome! :)

It it mafia that returns a price that isn't the lowest mall price?

-Paz
 
Last edited:

icon315

Member
Yes, it returns the price of the 5th item in the store...here is one that uses information from the coldfront marketplace

PHP:
string [item] prices;
foreach i in $items[A, B, C]{
int it = i.to_int();
string Mall = visit_url ("http://kol.coldfront.net/newmarket/itemgraph.php?itemid="+it+"&timespan=1&noanim=1");

string Item_price = substring ( Mall, (last_index_of ( Mall , "CURRENT AVG PRICE:" ) +42) , (last_index_of ( Mall , "</font> :: # BOUGHT THIS TIMESPAN:")-7) );
int Price = Item_price.to_int();
prices[i] = Price;
print(i);
print(Price);
}
map_to_file(prices,"prices.txt");
The only problem is that it will return 0 for items which have not been bought today, i could fix it, but i am lazy atm :p
 

fronobulax

Developer
Staff member
Note that if you are trying to build a mall bot that uses or requires up to date prices you will be shunned and scorned by this community.

Depending upon your purpose, historical_price() can replace mall_price(). Historical prices can be several days out of date but they are close enough for many purposes. More importantly, using them does not hit the KoL servers.

Since you are writing a file, if you are comfortable with tools besides ash, the file /data/mallprices.txt has the historical price information in table form and the data file itemdescs.txt can be extracted from the KoLmafia jar file to give you a mapping from item numbers to the more familiar string. Depending upon my mood, I have imported them both into a database as separate tables and used SQL to create a single more human friendly version. I have also used *nix shell scripting and the "join" command to do something similar.
 

Pazleysox

Member
Note that if you are trying to build a mall bot that uses or requires up to date prices you will be shunned and scorned by this community.

i'm *NOT* building a mall bot. I'm not looking for anything to automate buying anything. I'm just looking for a way to be able to scan the mall for my favorite items once in a while. I do it manually at the moment, and was just looking for a faster way to do it.
 

Theraze

Active member
Well, if you just have a list of fav items, you could look into Icon315's Daily Info script found here: http://kolmafia.us/showthread.php?4248-Daily-Info

It has a section where you can just list which items you'd like it to look up, and it'll give you the information out of Coldfront automatically. Only as accurate as they want to pass along, but it does make it easy if all you want is your fav stuff.
 
Top