Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zybez Old School Exchange and Guide API

Featured Replies

No externals were used in this class, all manual regex parsing, I will post usage later!

 

package scripts;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ZybezRSItem {
	private static String Json = "";
	
	public ZybezRSItem(String ItemName){

		try {
			Json = readUrl("http://forums.zybez.net/runescape-2007-prices/api/"+ItemName.replaceAll("\\s","+"));
		} catch (Exception e) {
			Json = "";
			e.printStackTrace();
		}
	}
	public int getAveragePrice(){
		
        Pattern pattern = Pattern.compile("(?<=\"average\":\")[0-9]+");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return(Integer.parseInt(matcher.group()));
		return 0;
	}
	public int getRecentHigh(){
		
        Pattern pattern = Pattern.compile("(?<=\"recent_high\":\")[0-9]+");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return(Integer.parseInt(matcher.group()));
		return 0;
	}
	public int getRecentLow(){
		
        Pattern pattern = Pattern.compile("(?<=\"recent_low\":\")[0-9]+");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return(Integer.parseInt(matcher.group()));
		return 0;
	}
	public int getHighAlchPrice(){
		
        Pattern pattern = Pattern.compile("(?<=\"high_alch\":\")[0-9]+");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return(Integer.parseInt(matcher.group()));
		return 0;
	}
	public String getImageUrl(){
        Pattern pattern = Pattern.compile("(?<=\"image\":\")[^\"]*");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return((matcher.group()).replace("\\", ""));
		return "";
	}
	public String getZybezID(){
        Pattern pattern = Pattern.compile("(?<=\"id\":\")[^\"]*");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return((matcher.group()).replace("\\", ""));
		return "";
	}
	
	
	private static String readUrl(String urlString) throws Exception {
        BufferedReader reader = null;
        try {
            URL url = new URL(urlString);
            reader = new BufferedReader(new InputStreamReader(url.openStream()));
            StringBuffer buffer = new StringBuffer();
            int read;
            char[] chars = new char[1024];
            while ((read = reader.read(chars)) != -1)
                buffer.append(chars, 0, read); 

            return buffer.toString();
        } finally {
            if (reader != null)
                reader.close();
        }

    }
	public static String getAllOffersAsJson(){
        Pattern pattern = Pattern.compile("(?<=\"offers\":\\[)[^\\]]*");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return((matcher.group()));
		return "";
	}
	public static Map<String, String[]> getAllOffersInMap(){
		Map<String, String[]> ReturnMap = new HashMap<String, String[]>();
		
		String JsonOffersAsString = getAllOffersAsJson();
		Pattern pattern = Pattern.compile("(?<=\"selling\":\")[0|1]");
        Matcher matcher = pattern.matcher(JsonOffersAsString);
        int sizeofreturn = 0;
        while (matcher.find()){
        	sizeofreturn = sizeofreturn + 1;
        }
        String[] SellingOrBuying = new String[sizeofreturn];
        String[] QuantityArray = new String[sizeofreturn];
        String[] PriceArray = new String[sizeofreturn];
        String[] DateArray = new String[sizeofreturn];
        String[] RSNameArray = new String[sizeofreturn];
        String[] ContactArray = new String[sizeofreturn];
        String[] NotesArray = new String[sizeofreturn];
        
        int counter = 0;
		pattern = Pattern.compile("(?<=\"selling\":\")[0|1]");
        matcher = pattern.matcher(JsonOffersAsString);
        while (matcher.find()){
        	SellingOrBuying[counter]=((matcher.group()));
        	counter = counter + 1;
        }
        counter = 0;	
        pattern = Pattern.compile("(?<=\"quantity\":\")[0-9]+");
        matcher = pattern.matcher(JsonOffersAsString);
        while (matcher.find()){
        	QuantityArray[counter]=((matcher.group()));
        	counter = counter + 1;
        }
        counter = 0;	
        pattern = Pattern.compile("(?<=\"price\":\")[0-9]+");
        matcher = pattern.matcher(JsonOffersAsString);
        while (matcher.find()){
        	PriceArray[counter]=((matcher.group()));
           	counter = counter + 1;
        }	
        counter = 0;	
        pattern = Pattern.compile("(?<=\"date\":\")[0-9]+");
        matcher = pattern.matcher(JsonOffersAsString);
        while (matcher.find()){
        	DateArray[counter]=((matcher.group()));
       		counter = counter + 1;
        }
       counter = 0;	
       pattern = Pattern.compile("(?<=\"rs_name\":\")[^\"]*");
       matcher = pattern.matcher(JsonOffersAsString);
       while (matcher.find()){
    	   RSNameArray[counter]=((matcher.group()));
           counter = counter + 1;
       }
       counter = 0;	
       pattern = Pattern.compile("(?<=\"contact\":\")[^\"]*");
       matcher = pattern.matcher(JsonOffersAsString);
       while (matcher.find()){
    	    ContactArray[counter]=((matcher.group()));
            counter = counter + 1;           
       }
       counter = 0;	
       pattern = Pattern.compile("(?<=\"notes\":\")[^\"]*");
       matcher = pattern.matcher(JsonOffersAsString);
       while (matcher.find()){
    	   NotesArray[counter]=((matcher.group()));
           counter = counter + 1;    
       }
       ReturnMap.put("selling", SellingOrBuying);
       ReturnMap.put("quantity", QuantityArray);
       ReturnMap.put("price", QuantityArray);
       ReturnMap.put("date", DateArray);
       ReturnMap.put("rs_name", RSNameArray);
       ReturnMap.put("contact", ContactArray);
       ReturnMap.put("notes", NotesArray);     
       
       return ReturnMap;
	}
	public String getFullJsonReturn(){
		return Json;
	}
}

Thanks :D I really didnt feel like doing this :)

 

Usage for those interested

ZybezRSItem coal = new ZybezRSItem("Coal");

int avgPrice = coal.getAveragePrice();

int highAlchPrice = coal.getHighAlchPrice();

Sweet could work it into some other scripts to know the exact GP p/h like EOC bots :D

  • 3 weeks later...

    public static String getName() {
        Pattern pattern = Pattern.compile("(?<=\"name\":\")[A-Za-z0-9\\s]{1,}");
        Matcher matcher = pattern.matcher(Json);
        while (matcher.find())
            return(matcher.group());
        return "null";
    }

 

Add that to it. It's needed for failsafes as some items will return the wrong price. ie. "roll" which doesn't exist on zybez so it will return like 1m

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.