Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_my_market_listings does not collect buy_orders #403

Open
Aarab228 opened this issue Aug 14, 2024 · 1 comment
Open

get_my_market_listings does not collect buy_orders #403

Aarab228 opened this issue Aug 14, 2024 · 1 comment

Comments

@Aarab228
Copy link

There is an account that is doing well and its json tree looks like this
image

And there's an account that has a json that looks like this
image

At the same time, buy_orders are the same on one and the other account. I tried to look at the market.py code in order to understand how it works in principle, but I failed. Also the documentation doesn't say anything about it and I don't know what to do. I often have such massive steam accounts, so I'm worried that I won't get buy_orders always. Is there an option to solve this issue?

@Aarab228
Copy link
Author

Aarab228 commented Aug 22, 2024

In general, as I understand it, this is a limitation of styme, and you will not get more than 1000. No matter how I modify the method - no way to get what I need. However, I realized that the method began to work a little better. Who is interested in the corrected method:

 def get_my_market_listings(self) -> dict:
        response = self._session.get(f'{SteamUrl.COMMUNITY_URL}/market')
        if response.status_code != HTTPStatus.OK:
                raise ApiException(f'There was a problem getting the listings. HTTP code: {response.status_code}')

        assets_descriptions = json.loads(text_between(response.text, 'var g_rgAssets = ', ';\r\n'))
        listing_id_to_assets_address = get_listing_id_to_assets_address_from_html(response.text)
        listings = get_market_listings_from_html(response.text)
        listings = merge_items_with_descriptions_from_listing(
            listings, listing_id_to_assets_address, assets_descriptions
        )

        if '<span id="tabContentsMyActiveMarketListings_end">' in response.text:
            n_showing = int(text_between(response.text, '<span id="tabContentsMyActiveMarketListings_end">', '</span>'))
            n_total = int(
                text_between(response.text, '<span id="tabContentsMyActiveMarketListings_total">', '</span>').replace(
                    ',', ''
                )
            )

            while n_showing < n_total:
                start = n_showing
                count = min(100, n_total - n_showing)
                url = f'{SteamUrl.COMMUNITY_URL}/market/mylistings/render/?query=&start={start}&count={count}'
                response = self._session.get(url)
                if response.status_code != HTTPStatus.OK:
                    raise ApiException(f'There was a problem getting the listings. HTTP code: {response.status_code}')

                jresp = response.json()
                listing_id_to_assets_address = get_listing_id_to_assets_address_from_html(jresp.get('hovers'))
                listings_2 = get_market_sell_listings_from_api(jresp.get('results_html'))
                listings_2 = merge_items_with_descriptions_from_listing(
                    listings_2, listing_id_to_assets_address, jresp.get('assets')
                )
                listings['sell_listings'] = {**listings['sell_listings'], **listings_2['sell_listings']}

                n_returned = len(listings_2['sell_listings'])
                if n_returned < count:
                    break

                n_showing += n_returned

        return listings

And confirmation of my words that you won't get more than 1000: (logs by my script)

00:14:35  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=10&count=100 HTTP/11" 200 14949
00:14:36  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=110&count=100 HTTP/11" 200 15558
00:14:37  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=210&count=100 HTTP/11" 200 11490
00:14:37  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=310&count=100 HTTP/11" 200 13834
00:14:38  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=410&count=100 HTTP/11" 200 12969
00:14:38  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=510&count=100 HTTP/11" 200 14343
00:14:39  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=610&count=100 HTTP/11" 200 13475
00:14:39  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=710&count=100 HTTP/11" 200 15670
00:14:40  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=810&count=100 HTTP/11" 200 14310
[00:14:40]  5 min delay
00:19:41  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market/mylistings/render/?query=&start=910&count=91 HTTP/11" 200 13574
00:19:41  DEBUG      | [Unknown] | https://steamcommunity.com:443 "GET /market HTTP/11" 200 None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant