Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

warfront1

Zybez API (No Externals)

Recommended Posts

A quick API to get all of Zybez's information, even the not so useful things.

Tribot is extremely slow at the moment, probably another DOS. 

I'll post some basic usage once it clears up a bit!

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;	}}
Edited by warfront1
  • Like 1

Share this post


Link to post
Share on other sites

Here is my fix for zybez block. Changed the user agent in readUrl().

package scripts;import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URL;import java.net.URLConnection;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;        URLConnection uc = null;        try {            URL url = new URL(urlString);            uc = url.openConnection();            uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");            uc.connect();            reader = new BufferedReader(new InputStreamReader(uc.getInputStream()));            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 for this!

 

Share this post


Link to post
Share on other sites

Seems to me like Zybez has blocked requests from the Tribot client. Is it just me or has anyone else come across this problem?

 

Yes they have. All you do is make Zybez think that you are using Mozilla firefox or some other legit browser, you can trick Zybez by editing the headers in the requestUrl.

 

This is from the code posted above:

private static String readUrl(String urlString) throws Exception {BufferedReader reader = null;URLConnection uc = null;try {URL url = new URL(urlString);uc = url.openConnection();uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");uc.connect();reader = new BufferedReader(new InputStreamReader(uc.getInputStream()));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();}}
Edited by MegaMan_Alpha

Share this post


Link to post
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.


  • Our picks

    • Gradle is a build tool used to accelerate developer productivity.

      We recently setup a Maven repository (TRiBot Central) to make it easier for scripters to create scripts. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-central/-/packages

      Furthermore, we've released a simple Gradle project to make it easy to run TRiBot and develop scripts for it. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-gradle-launcher

      The goals of TRiBot Central are to:

      Deliver updates to TRiBot faster


      Better organize TRiBot's dependencies (AKA dependancies)


      Make it easier to develop scripts for TRiBot


      Make it easier to use and run TRiBot


      Note: TRiBot won't be able to run scripts from within this project until TRiBot's next release.
        • Like
      • 9 replies
    • Hi everyone,

      I'd like to thank everyone for their patience in this transition period. Since last week, we've worked out the remaining bugs with this integration.

      Some users have still been having issues with connecting their forums account to their Auth0 account. To resolve this, we've imported all forums accounts into Auth0.

      Unfortunately, the accounts which were imported today were using an unsupported password hashing algorithm. Hence, random passwords were set during the import.

      What does this mean for me?

      If you've previously linked your forums account to your Auth0 account, you don't have to do anything. Nothing changes for you.


      If you haven't logged in via our new login yet,

      Try logging in with your forums email address and the last password you used


      If you are unable to login, please use the "Forgot password" tool on the login page:
      Follow the instructions to reset your password
       
        • thonking
        • Like
      • 15 replies
    • Hello everyone,

      Last week we tried to roll out Auth0 Login, but we lost that battle. Now it's time to win the war!

      Important changes

      When logging into the client, you'll now have to enter your Auth0 account credentials instead of your forums credentials

      Note: 2FA is still handled through your forums account (for the time being)



      Changes for existing users

      You'll have to link your Auth0 account to your forums account here: https://tribot.org/forums/settings/login/?service=11


      Auth0 accounts have been created for most existing users. Please use your forums email address and password to login.



      Important notes

      Make sure to verify your email address upon creating a new Auth0 account


      When we mention your Auth0 account, we mean your account used for auth.tribot.org as displayed below
      • 81 replies
    • To better support the upcoming changes (TRiBot X, new repository), we're switching our login handler to Auth0. Instead of logging in with the standard form, you'll now be required to login through our Auth0 application.

      All existing accounts which have been used within approximately the past year have been imported into Auth0 using the same email and password combination which has been stored on the forums.

      What does this mean for users?

      Your account credentials are now even more securely stored


      You'll be able to login via Facebook, Google, and others in the future


      Is there anything users have to do differently now?

      Existing users: You'll have to login with the standard login, open your Account Settings, then link your Auth0 account


      New users: You'll be redirected to our Auth0 app (auth.tribot.org) where you'll be able to create an account


      Why was this change made?

      The new apps we are creating (such as the new repository) aren't able to use the forums to handle user logins


      To centralize all user accounts in one area


      To ensure that the client login doesn't go down when the forums are having problems


      To speed up our development


      Other considerations

      There's no documentation or official support for using Invision Community combined with Auth0, so there are still a few kinks we're working out


      We're in the works of creating an account management panel specifically for Auth0 accounts (ETA August)


      It's not possible to change email addresses for the time being (this will be resolved this August)


      Changing passwords is a weird process for the time being. To change your password, you'll have to use the "Don't remember your password" tool on the Auth0 login page
        • Like
      • 11 replies
    • Over the past month, we've been working hard on TRiBot's new repository - a much needed update. This change has been deemed necessary for TRiBot X, and will allow us to really speed up development of all aspects of TRiBot.

      Today we are going to share what we've been working on!


      Now you must be wondering what kind of features the new repository will have.... well, you'll have to be patient for a little while longer. We're still figuring out various technical aspects so we can't provide answers to all possible questions. We're also focusing on development rather than writing about it so that everyone can get access to our latest developments at lightning speed. I will however answer a few users' questions.

      We're planning on a release of this early to mid August, giving users some goodies before TRiBot X's release.

      Thank you all for being patient. I hope everyone is excited as much as I am!
        • Like
      • 17 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...