Created
May 23, 2015 14:37
-
-
Save NeilHanlon/c4e746765f9475dba43b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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