Spork Posted January 9, 2017 Share Posted January 9, 2017 (edited) A buddy of mine requested this over Skype, and as I already had it written as a CLI app, I just converted it to work with OSBot. I guess it's nice for the GUI but not very resource friendly haha. The script iterates through IDs on the GE, checking if it's valid or nah, and then simply log()'s them. Pls write your own logger if you actually want to make use of it lmao. EDIT/WARN: Due to osrs website, this code currently does not work. Will have to change useragent later on and probably use Apache's web lib in further edits. Pls donot use dis for anything other than an example. Jar: http://www.filedropper.com/osgedump Code: package main; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; @ScriptManifest(name = "Simple GE Dumper", author = "Spork", version = 13.37, info = "Creates prices.txt...", logo = "") public class Main extends Script { /* * Simple GE Dumper * Should start running at item 0, which is invalid anyway... * Good luck! */ String BASE_URL = "http://services.runescape.com/m=itemdb_oldschool/lookup/viewitem?obj="; int itemId; State state; public enum State { STARTUP, VALID, INVALID, ERROR } @[member='Override'] public void onStart() { state = State.STARTUP; itemId = 0; } @[member='Override'] public void onExit() { //Maybe gonna put logging here. } @[member='Override'] public int onLoop() { try (final BufferedReader reader = new BufferedReader(//Creates BufferedReader new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(itemId).toString()).openStream()))) { //Creates InputStream for the URL to GE appending itemId onto it if (reader.toString().contains("Sorry, there was a problem with your request.")) { state = State.INVALID; //The item is unavailable or not a tradable item } else { state = State.VALID; //WOO String name = getBetween(reader.toString(), "<title>", " - "); //Most useful function: getBetween() String price = getBetween(reader.toString(), "Current Guide Price <span title='", "'"); log(name + " " + price); //TODO: Logging to file } } catch (MalformedURLException e) { state = State.ERROR; } catch (IOException e) { state = State.ERROR; } if (state == State.ERROR) { try { sleep(5000); //Sleep for a while so you can look at it and be like ?? y } catch (InterruptedException e) { e.printStackTrace(); } } itemId++;//Next iteration return 100; } @[member='Override'] public void onPaint(Graphics2D g) { // This is where you will put your code for paint(s) g.drawString("Status: " + state, 30, 300); g.drawString("Checking Item: " + itemId, 30, 280); } public static String getBetween(String haystack, String pre, String post) { Pattern pattern = Pattern.compile(Pattern.quote(pre) + "(.+?)" + Pattern.quote(post)); Matcher matcher = pattern.matcher(haystack); if (matcher.find()) { return haystack.substring(matcher.start(1), matcher.end(1)); } return "No match could be found."; } } Edited January 9, 2017 by Spork 1 Quote Link to comment Share on other sites More sharing options...
vindictivebud Posted January 9, 2017 Share Posted January 9, 2017 looks good ill try it out. Quote Link to comment Share on other sites More sharing options...
Juggles Posted January 9, 2017 Share Posted January 9, 2017 Interesting addition Quote Link to comment Share on other sites More sharing options...
cheatingisfun Posted January 22, 2017 Share Posted January 22, 2017 Hope you get it back up soon, friend.. Quote Link to comment Share on other sites More sharing options...