Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
baileyr12

How to make a java Item Value Searcher with RSBuddy

6 posts in this topic

I am trying to build a program that will import the page "https://rsbuddy.com/exchange", take a .txt file filled with item names, and search and return the name of the item and it's value. I am new to webpage scraping and could use some help!

This is the code I have so far(it's not much...)

   

import org.jsoup.Jsoup;
import org.jsoup.nodes.*;
import org.jsoup.select.Elements;
import java.io.IOException;
    
    public class RuneMerch {
    
        public static void main(String[] args) throws IOException {
            Document d = Jsoup.connect("https://rsbuddy.com/exchange").timeout(6000).get());
            Elements ele = d.select("")
    
        }
    }

 

Share this post


Link to post
Share on other sites

private static final String STATS_URL = "https://api.rsbuddy.com/grandExchange?a=guidePrice&i=";

 

dont use jsoup. use a json api

Share this post


Link to post
Share on other sites
26 minutes ago, Starfox said:

private static final String STATS_URL = "https://api.rsbuddy.com/grandExchange?a=guidePrice&i=";

 

dont use jsoup. use a json api

Alright, so how would I do that? Or where should I look to learn how to do that..?

Share this post


Link to post
Share on other sites

google json java api and there will be open source apis all over, same with guides.

Share this post


Link to post
Share on other sites

Here's an example in python. Depending on your programming knowledge this may be helpful or confusing.

import json
import requests

HEADERS = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36',
    'cookie': 'redacted cloudflare cookie'
}

RSBUDDY_EXCHANGE_NAMES_URL = 'https://rsbuddy.com/static/exchange/names.json'
RSBUDDY_EXCHANGE_ITEM_ID_PRICE_URL = 'https://api.rsbuddy.com/grandExchange?a=guidePrice&i='


def get_id(name, names):
    for k, v in names.items():
        if v['name'] == name:
            return k


def get_price(item_id):
    price = json.loads(requests.get(RSBUDDY_EXCHANGE_ITEM_ID_PRICE_URL + str(item_id), headers=HEADERS).text)
    return price['overall']


def main():
    names = json.loads(requests.get(RSBUDDY_EXCHANGE_NAMES_URL, headers=HEADERS).text)
    items_file = open('items.txt', 'r')
    prices_file = open('prices.txt', 'w')
    for line in items_file:
        line = line.replace('\n', '')
        prices_file.write(line + ':' + str(get_price(get_id(line, names))) + '\n')
    items_file.close()
    prices_file.close()


main()

 

Edited by Encoded

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.