Use CaptiveResponseParser to parse data in login() - anticapum - Handle Università Politecnica delle Marche captive portal
 (HTM) hg clone https://bitbucket.org/iamleot/anticapum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) changeset 3c6d2f27a9facbb07e6db6bfb0fe0358bf39f61b
 (DIR) parent c10ce3199d0825a9896c00f0aac8bc4020175de2
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Thu, 11 Jan 2018 23:01:16 
       
       Use CaptiveResponseParser to parse data in login()
       
       Parse interesting data that will be needed to renew()/logout() and return it in
       as a dict.
       
       Diffstat:
        anticapum.py |  13 ++++++++++++-
        1 files changed, 12 insertions(+), 1 deletions(-)
       ---
       diff -r c10ce3199d08 -r 3c6d2f27a9fa anticapum.py
       --- a/anticapum.py      Thu Jan 11 22:57:42 2018 +0100
       +++ b/anticapum.py      Thu Jan 11 23:01:16 2018 +0100
       @@ -76,6 +76,9 @@
        
        def login(username, password):
            """Login to the captive portal using provided username and password
       +
       +    Return a dictionary with all the needed elements extracted from the form
       +    needed by renew() and logout().
            """
            auth = parse.urlencode({
                'username': username,
       @@ -88,7 +91,15 @@
            sc = ssl.SSLContext()
            sc.verify_mode = ssl.CERT_NONE
            with request.urlopen(ANTICAPUM_URL_LOGIN, data=auth, context=sc) as f:
       -        pass
       +        p = CaptiveResponseParser()
       +        p.feed(f.read().decode())
       +        return {
       +            'username': p.username,
       +            'ip': p.ip,
       +            'timestamp': p.timestamp,
       +            'sid': p.sid,
       +            'pulsante': p.pulsante,
       +        }
        
        
        if __name__ == '__main__':