Skip to content

Instantly share code, notes, and snippets.

@NeilHanlon
Created May 23, 2015 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeilHanlon/c4e746765f9475dba43b to your computer and use it in GitHub Desktop.
Save NeilHanlon/c4e746765f9475dba43b to your computer and use it in GitHub Desktop.
__author__ = 'Neil'
from bs4 import BeautifulSoup
import urllib2
def main():
steam_page = urllib2.urlopen("http://steamcommunity.com/market/search?appid=730#p1_price_asc")
soup = BeautifulSoup(steam_page)
items = soup.findAll("div", {"class": "market_listing_row"})
item_list = []
for item in items:
item_name = item.find("span", {"class": "market_listing_item_name"}).contents[0].strip()
market_value = item.find("span", {"class": "market_table_value"}).contents[3].contents[0].strip("$ ")
game_name = item.find("span", {"class": "market_listing_game_name"}).contents[0].strip()
quantity = item.find("span", {"class": "market_listing_num_listings_qty"}).contents[0].strip()
item_list.append({
"name": item_name,
"value": market_value,
"game": game_name,
"quantity": quantity
})
print item_list
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment