Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Go back to extracting the number of discounts first
Browse files Browse the repository at this point in the history
  • Loading branch information
rg3 committed Nov 25, 2011
1 parent da485cc commit 81ebbf3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions steam_discounts
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,27 @@ class DiscountsParser(HTMLParser.HTMLParser):
if __name__ == '__main__':
# Extra imports
import os
import urllib
import re
import subprocess
import sys
import urllib

# Constants.
MAX_DISCOUNTS = 1000
TITLE_WIDTH = 40

# Get the number of discounts first.
conn = urllib.urlopen('http://store.steampowered.com/')
page = conn.read()
conn.close()
mo = re.search(r'<span id="tab_Discounts_count_start">.*?of +(\d+)', page)
if mo is None:
sys.exit('ERROR: unable to extract the total number of discounts')
max_discounts = int(mo.group(1))

# Retrieve the discounts.
conn = urllib.urlopen(
'http://store.steampowered.com/search/tab?bHoverEnabled=true&style=' +
'&navcontext=1_4_4_&tab=Discounts&start=0&count=%d' % MAX_DISCOUNTS)
'&navcontext=1_4_4_&tab=Discounts&start=0&count=%d' % max_discounts)
page = conn.read()
conn.close()

Expand Down

0 comments on commit 81ebbf3

Please sign in to comment.