Created
June 15, 2017 01:30
-
-
Save 5S/b9c8ac2f6d5daaa89620dc065c766317 to your computer and use it in GitHub Desktop.
某大学の WiFi スポットに自動でログインするやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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