Skip to content

Instantly share code, notes, and snippets.

@5S
Created June 15, 2017 01:30
Show Gist options
  • Save 5S/b9c8ac2f6d5daaa89620dc065c766317 to your computer and use it in GitHub Desktop.
Save 5S/b9c8ac2f6d5daaa89620dc065c766317 to your computer and use it in GitHub Desktop.
某大学の WiFi スポットに自動でログインするやつ
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
username = 'sXXXXXXX'
password = 'PASSWORD'
print('Signing in to TGWIFI...')
try:
s = requests.Session()
r = s.get('http://go.microsoft.com/fwlink/?LinkID=219472&clcid=0x409')
url = r.headers['location']
r = s.get(url)
soup = BeautifulSoup(r.content, 'lxml')
form = soup.find('form')
param = {
'buttonClicked': '4',
'redirect_url': 'go.microsoft.com/fwlink/?LinkID=219472&clcid=0x409',
'err_flag': '0',
'username': username,
'password': password
}
s.post('https://wlgate.nc.tohoku-gakuin.ac.jp/login.html', data=param)
print('Success!')
except KeyError:
print('Error: You have already signed in.')
except Exception:
print('Error: You may not connected to the TGWIFI.')
input('Press any key to exit...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment