Jump 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 price fetcher

Featured Replies

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URLEncoder;
 
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
 
public class PriceFetcher {
    
    public static double getAvgPrice(String q) {
        HttpURLConnection connection = null;
        BufferedReader rd  = null;
        StringBuilder sb = null;
        String line = null;
      
        URL serverAddress = null;
      
        try {
            serverAddress = new URL("http://forums.zybez.net/runescape-2007-prices/api/item/" + URLEncoder.encode(q, "UTF-8"));
            connection = null;
    
            connection = (HttpURLConnection)serverAddress.openConnection();
            connection.setRequestMethod("GET");
            connection.setDoOutput(true);
            connection.setReadTimeout(10000);
            connection.setRequestProperty("User-Agent", "Bot");
                      
            connection.connect();
            
            rd  = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            sb = new StringBuilder();
          
            while ((line = rd.readLine()) != null)
            {
                sb.append(line + '\n');
            }
            JsonParser parser = new JsonParser();
            JsonObject obj = parser.parse(sb.toString()).getAsJsonObject();
            if (obj.has("average")) {
                return obj.get("average").getAsDouble();
            } else if (obj.has("error")) {
                System.out.println(obj.get("error").toString());
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (ProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally
        {
            connection.disconnect();
            rd = null;
            sb = null;
            connection = null;
        }
        return Double.NaN;
    }
    
    public static void main(String[] args) {
        System.out.println(getAvgPrice("0"));                       // => NaN
        System.out.println(getAvgPrice("Lobster"));             // => 226.689
        System.out.println(getAvgPrice("3+@@#$@.---"));    // => NaN
        System.out.println(getAvgPrice("Blue partyhat"));    // => 48370.227
    }
}

Requires google-gson in your build path for parsing the JSON response!

Edited by mixuhd

Impressive, now I'm not a java programmer, but why this part:

 

public static void main(String[] args) {
        System.out.println(getAvgPrice("0"));                       // => NaN
        System.out.println(getAvgPrice("Lobster"));             // => 226.689
        System.out.println(getAvgPrice("3+@@#$@.---"));    // => NaN
        System.out.println(getAvgPrice("Blue partyhat"));    // => 48370.227

Impressive, now I'm not a java programmer, but why this part:

 

public static void main(String[] args) {

        System.out.println(getAvgPrice("0"));                       // => NaN

        System.out.println(getAvgPrice("Lobster"));             // => 226.689

        System.out.println(getAvgPrice("3+@@#$@.---"));    // => NaN

        System.out.println(getAvgPrice("Blue partyhat"));    // => 48370.227

 

This is how you test it...

  • 1 month later...

This deserves to be used more tongue.png.

Ty mixu.

Edited by Merccy

Very nice

 

but is it possible to grab every item in an area with the value of above 200 and list them ?
?

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.