]> git.madduck.net Git - code/qantas-login.git/blob - qantas-login

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

initial checkin
[code/qantas-login.git] / qantas-login
1 #!/usr/bin/python3
2 # © 2020 martin f. krafft <madduck@madduck.net>
3 # Released under the terms of the Artistic Licence 2.0
4 # https://git.madduck.net/code/wifionice-login.git
5
6 URL='http://qantas.com.au'
7
8 import mechanicalsoup
9 import requests
10
11 # open any URL
12 browser = mechanicalsoup.StatefulBrowser()
13 browser.open(URL)
14
15 # get the captive page, and extract the URL that'll eventually grant us access
16 page = browser.get_current_page()
17 granturl = page.find(id='frequentflyerguestbutton').attrs['href']
18
19 # Qantas now expects a HEAD request with a specific header to the same URL
20 url = browser.get_url()
21 req = requests.head(url=url, headers={'X-Requested-With':'XMLHttpRequest'})
22
23 # and then a redirect to the granturl
24 browser.open(granturl)
25
26 # and now you're logged in…