Kunci untuk memecahkan masalah seperti ini adalah mengetahui bagaimana cara mengajukan pertanyaan. Saya mencari di Google mencari "cara mengakses wifi roti panera" dan menemukan permata ini.
Artikel ini memiliki beberapa skrip yang dapat digunakan untuk memfasilitasi masuk otomatis. Saya telah memilih untuk menyertakan contoh untuk Panera Bread yang memanfaatkan pustaka Mekanis Python.
Solusinya memanfaatkan direktori NetworkManagerdispatcher.d
untuk menjalankan skrip setiap kali antarmuka jaringan tertentu naik atau turun. Artikel merinci skrip yang akan Anda tempatkan di direktori ini /etc/NetworkManager/dispatch.d
,, dipanggil 07-autologin_openwifi
. Ini skripnya:
#!/bin/bash
#------------------------------
# By Fahad Alduraibi
# Last update: June 12, 2012
# Version: 1.1
#------------------------------
export LC_ALL=C
LogFile="/var/log/07-WIFI_ACCESS.log"
# The parameters that get passed to the script are:
# $1 = The interface name ( eth0, wlan0 ...etc)
# $2 = Interface status ( "up" or "down" )
# Check if wireless status is up
# I have two wifi cards in my laptop, named "wlan0 and wlan1"
# so I use regular expression "wlan[01]" to match both of them.
if [[ "$1" =~ wlan[01] && $2 == "up" ]]; then
# Get the network name from "iwconfig" or (can also locate the network based on IP or MAC address if needed)
ESSID=$(/sbin/iwconfig $1 | grep ESSID | cut -d'"' -f2)
# Record the date and time for debugging purposes only
echo "[`date`] ESSID=($ESSID)" >> $LogFile
# If the wireless name matches then run its python script
if [[ "$ESSID" == "BCPL-PUBLIC-WIFI" ]]; then
/usr/bin/python /myscripts/baltimore-county_library_wifi.py 1>> $LogFile 2>&1
elif [[ "$ESSID" == "PANERA" ]]; then
/usr/bin/python /myscripts/panera.py 1>> $LogFile 2>&1
elif [[ "$ESSID" == "Nordstrom_Wi-Fi" ]]; then
/usr/bin/python /myscripts/nordstrom.py 1>> $LogFile 2>&1
#elif .... (you can add more open wifi here)
fi
fi
#if [[ "$1" =~ wlan[01] && $2 == "down" ]]; then
##If you want to do somehting when the network is down
#fi
Dan inilah skrip roti Panera panera.py
:
#------------------------------
# By Fahad Alduraibi
# Last update: June 12, 2012
# Version: 1.1
#------------------------------
import mechanize
import sys
br = mechanize.Browser()
br.set_handle_equiv(True)
#br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0')]
testURL = 'http://fadvisor.net/blog/'
response = br.open(testURL)
if response.geturl() == testURL:
print "FAD: You are already logged in to Panera."
sys.exit()
try:
forms = mechanize.ParseResponse(response, backwards_compat=False)
except:
print "FAD: Error in parsing forms, Am I already logged in to Panera?"
sys.exit()
response.close
form = forms[0]
#print form
#print "----------------------------------- Login"
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
#print form
#print "----------------------------------- Validate"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
#print form
#print "----------------------------------- ConfirmLogin New"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
#print form
#print "----------------------------------- ConfirmLogin Validate"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
#print form
#print "----------------------------------- CompleteLogin New"
#print
request = form.click()
response = mechanize.urlopen(request)
forms = mechanize.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
#print form
#print "----------------------------------- HttpLoginRequest"
#print
request = form.click()
response = br.open(request)
#print response.read()
response.close()
print "--- Panera Done ---"
Saya mendorong Anda untuk membaca seluruh artikel jika Anda tertarik pada metode lain untuk melakukan login otomatis. Artikel ini memiliki beberapa jaringan WiFi terbuka yang ditulis untuk wilayah Baltimore, MD.
wget
program yang diinstal?