Changeset 348 for misc


Ignore:
Timestamp:
Nov 20, 2011, 11:14:03 AM (13 years ago)
Author:
Rick van der Zwet
Message:

Response got changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/geluksnummers-donaldduck.py

    r251 r348  
    1313  username = sys.argv[1]
    1414  password = sys.argv[2]
    15   clubpasnummer = sys.argv[3]
     15  clubpasnummers = sys.argv[3:]
    1616except:
    17   print "Usage %s <username> <password> <clubpasnummer>" % sys.argv[0]
     17  print "Usage %s <username> <password> <clubpasnummer> [<clubpasnummer2> <clubpasnummer3> ...]" % sys.argv[0]
    1818  sys.exit(1)
    1919
     
    3030
    3131# Find the numbers itself
    32 m = re.search('<span class="sifr-header">([^<]*)<',response2.read())
     32m = re.search('<span class="cufon-diary">([^<]*)<',response2.read())
    3333if not m:
    3434  print "Something is wrong, unable to find the geluksnummers"
     
    3636
    3737numbers = [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])
     38for 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.