Thursday, December 31, 2009

Get A List Of Steam Games

Update: see here for a new version which works on the new steam site.

Using Python and Beautiful Soup. Just a quick (ugly) script thrown together for future reference.

from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import re
import codecs

html_text = urlopen('').read()
soup = BeautifulSoup(html_text)
f ='./output.txt', 'w', 'iso-8859-1')

pages = 1

print "-- Retrieving number of pages..."
for link in soup.findAll('a', attrs={'href' : re.compile("\?sort_by=&sort_order=ASC&category1=998&page=\d+")}):
        page = int(link.string)
        if page > pages:
            pages = page
    except ValueError:

print "-- Pages found:",pages

for page in range(1,pages+1):
    print "-- Retrieving page:",page
    html_text = urlopen(''+str(page)).read().decode('iso-8859-1')
    soup = BeautifulSoup(html_text)
    for item in soup.findAll('div', attrs={'class' : "global_area_tabs_item_txt"}):


No comments :

Post a Comment