0

So i am trying to get some data from a website by using JSoup, and i am not sure how.

This is the code i have been using and it does not work:

public static  Document doc;

public static Elements elementPrice;

public void getDocument()
{
    try 
    {

        doc = Jsoup.connect("https://steamcommunity.com/market/search?appid=730&q=ak47+jaguar+factory-new").get();

        elementPrice = doc.select("market_table_value");

        System.out.println(elementPrice);


    } catch (IOException e) 
    {
        e.printStackTrace();
    }
}
}

I am trying to get data from this site: https://steamcommunity.com/market/search?appid=730&q=ak47+jaguar+factory-new

And the data/attribute i am trying to get is this: Pris från:
35,36€

Which is the price of a csgo item in steam.

And now i wonder why this doesen't work.

Thanks for any help! :)

1 Answer 1

1

select uses CSS selectors syntax so if you want to describe elements by its class use .className (notice dot at start). So try with

elementPrice = doc.select(".market_table_value");
//                         ^--add this dot

You can also use getElementsByClass method instead of select and pass name of class directly, without any CSS like

elementPrice = doc.getElementsByClass("market_table_value");
Sign up to request clarification or add additional context in comments.

9 Comments

This works, im getting results but they are not accurate, like when i update the website i get different results. Any idea why that is?
Sorry but I don't know how to help you solve this problem because I don't understand what is the problem. You need to explain (1) what values you get (2) what values you expect (3) and why you expect such values.
I am expecting to get the current price of an item, which updates constantly and im getting different prices.
How update process looks like? Are you the one who updates this value? Are you able to see updated price on site?
Yeah you can see it yourself, here's the website: steamcommunity.com/market/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.