Changeset 348
- Timestamp:
- Nov 20, 2011, 11:14:03 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/geluksnummers-donaldduck.py
r251 r348 13 13 username = sys.argv[1] 14 14 password = sys.argv[2] 15 clubpasnummer = sys.argv[3]15 clubpasnummers = sys.argv[3:] 16 16 except: 17 print "Usage %s <username> <password> <clubpasnummer> " % sys.argv[0]17 print "Usage %s <username> <password> <clubpasnummer> [<clubpasnummer2> <clubpasnummer3> ...]" % sys.argv[0] 18 18 sys.exit(1) 19 19 … … 30 30 31 31 # Find the numbers itself 32 m = re.search('<span class=" sifr-header">([^<]*)<',response2.read())32 m = re.search('<span class="cufon-diary">([^<]*)<',response2.read()) 33 33 if not m: 34 34 print "Something is wrong, unable to find the geluksnummers" … … 36 36 37 37 numbers = [n for n in re.split('\s*-\s*', m.group(1)) if n] 38 print "\n".join(numbers) 39 if any([clubpasnummer.endswith(x) for x in numbers]): 40 print "YES; een prijs!" 41 else: 42 print "NO; volgende week weer een kans" 43 # Invalid HTML, else use the 'proper parser' 44 # import lxml 45 # root = lxml.etree.parse(response2) 46 # print lxml.etree.tostring(root.xpath(".//span[@class='sifr-header']")[0]) 38 for clubpasnummer in clubpasnummers: 39 print "Geluksnummers van deze week:", ",".join(numbers) 40 if any([clubpasnummer.endswith(x) for x in numbers]): 41 print "[%s] YES; heeft een prijs!" % clubpasnummer 42 else: 43 print "[%s] HELAAS; volgende week weer een kans" % clubpasnummer
Note:
See TracChangeset
for help on using the changeset viewer.