Daniel Prinsloo
Daniel Prinsloo

Reputation: 149

Selenium Steam community market listings python

I am trying to write a program which would open a steam community page and would then read the first value in the table of prices. I will then do stuff with this afterwards. I do not want to use the steam api if that is anyones suggestion i would like to know how to select the first id in the table because it will constantly change and I cannot define a set id and trying to locate by class is proving difficult.

My code can currently open the webpage that is not an issue

Example of item from community market.

<div class="market_listing_right_cell market_listing_their_price">

<span class="market_table_value">
    <span class="market_listing_price market_listing_price_with_fee"></span>
    <span class="market_listing_price market_listing_price_without_fee"></span>

Upvotes: 1

Views: 1021

Answers (1)

alecxe
alecxe

Reputation: 474191

From what I understand, you are working with this page.

To get the list of prices, iterate over results containing in the div elements with market_listing_row class and get the text of the elements with market_listing_their_price class:

for result in driver.find_elements_by_css_selector("div.market_listing_row"):
    price = result.find_element_by_css_selector("div.market_listing_their_price")
    print price.text.strip()

This would print price results like these:

Starting at: $0.63
Starting at: $0.27

Upvotes: 2

Related Questions