Jump to content

Getting high alch prices


anderiel

Recommended Posts

On 5/14/2018 at 7:06 AM, anderiel said:

i kind of hoped for a simpler solution than scraping sites.

The simplest solution is just creating an enum and hardcoding the alch values.

 

22 hours ago, Plaxonn said:

Very easy dude!

Alchmate is the way.

I hope I'm not breaking the rules by saying that, no advertisment intended.

He asked for a solution that didn't involve scraping sites

Link to comment
Share on other sites

On 5/14/2018 at 12:49 PM, anderiel said:

I was wondering if there is a way to get high alch prices. From an API or something, anything. I have found this : http://forums.zybez.net/runescape-2007-prices/api/rune axe , but all my requests to that site from application end in 503.

Well then he can use OSBuddy. Runelite's API is open source, might be on there.

Link to comment
Share on other sites

18 hours ago, ThatGamerBlue said:

Not sure if OSBot has a getPrice() type function for items (couldn't see it in the API) which would return the item's price in a general store (example from another client), but if it does you can multiply that value by 0.6 for high alch, 0.4 for low alch.

Nice! This i did not know. Not sure if osbot has such a function, but rsbuddy has api that gives you store prices that i can multiply. I can work with that, thanks.

Link to comment
Share on other sites

10 hours ago, anderiel said:

Nice! This i did not know. Not sure if osbot has such a function, but rsbuddy has api that gives you store prices that i can multiply. I can work with that, thanks.

Yes, you can use https://rsbuddy.com/exchange/summary.json

Example (using https://github.com/fangyidong/json-simple)

 

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public final class AlchValues {

    private static final float STORE_PRICE_TO_HIGH_ALCH_MULTIPLIER = 0.6f;
    private static final float STORE_PRICE_TO_LOW_ALCH_MULTIPLIER = 0.4f;

    private final JSONObject ITEMS_JSON;

    public AlchValues() throws IOException, ParseException {
        ITEMS_JSON = getItemsJSON();
    }

    public static void main(String[] args) {
        AlchValues alchValues = null;
        try {
            alchValues = new AlchValues();
        } catch (IOException | ParseException e) {
            System.err.println("Failed to fetch alch values");
            System.exit(1);
        }

        System.out.println("Yew logs store price: " + alchValues.getStorePrice(1515));
        System.out.println("Yew logs high alch: " + alchValues.getHighAlchValue(1515));
        System.out.println("Yew logs low alch: " + alchValues.getLowAlchValue(1515));
    }

    private JSONObject getItemsJSON() throws IOException, ParseException {
        URL url = new URL("https://rsbuddy.com/exchange/summary.json");
        URLConnection con = url.openConnection();
        con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
        con.setUseCaches(true);

        JSONObject itemsJSON;

        try (InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream());
             BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
            JSONParser jsonParser = new JSONParser();
            itemsJSON = (JSONObject) jsonParser.parse(bufferedReader);
        }

        return itemsJSON;
    }

    public int getHighAlchValue(final int itemID) {
        return (int) (getStorePrice(itemID) * STORE_PRICE_TO_HIGH_ALCH_MULTIPLIER);
    }

    public int getLowAlchValue(final int itemID) {
        return (int) (getStorePrice(itemID) * STORE_PRICE_TO_LOW_ALCH_MULTIPLIER);
    }

    public int getStorePrice(final int itemID) {
        return Math.toIntExact((long) getItemJSON(itemID).get("sp"));
    }

    private JSONObject getItemJSON(final int itemID) {
        return (JSONObject) ITEMS_JSON.get(String.valueOf(itemID));
    }
}


Output:
 

Yew logs store price: 160
Yew logs high alch: 96
Yew logs low alch: 64


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...