该程序会每隔至少1秒进行一次护照状态查询
需要修改passportNo变量为自己的护照号码。
另外需要pip install beautifulsoup4
#coding=utf-8
import requests
import time
from bs4 import BeautifulSoup
import os sleepTime = 0.1
os.system('clear') beforeTime = time.strftime('%Y-%m-%d %H:%M:%S')
while(1): passportNo = 'E1234567'
data = {
"AJAXREQUEST":"_viewRoot",
"passportTrackerPage:psptTrackerForm":"passportTrackerPage:psptTrackerForm",
"passportTrackerPage:psptTrackerForm:j_id34:j_id35:passportNo":passportNo,
"com.salesforce.visualforce.ViewState":"i:AAAAWXsidCI6IjAwREMwMDAwMDAwUGh1UCIsInYiOiIwMDAwMDAwMDAwMDAwMDAiLCJhIjoidmZlbmNyeXB0aW9ua2V5IiwidSI6IjAwNUMwMDAwMDAzWVpFdCJ9YgCa1fTpZtG6Tnt/I8/Q9X5JpiCoPGBdA1+XxAAAAVwfbi4VcKGoESJ5gqtSHd0cqdkbrHJCsGies/SlwqDPh99UABcrOuG+rSYsQBNbydPVC/rVatsdMI/3E9woTcZWsfLDrNUYhVlgUr974w+kkOmfSBYfmBfUyeY5y2dS7OW49/vQ9xeT/vF4UM0dh3rLGpmfLA/ENZ21dY6NCC6abnHrzkIXwL493yTI3OtQyuC1AVP/GDRU2dhHiTqRHA2kJlawOe+WLZalj668boA2H+EGS2VKYw4tx6v5iTd1i59Vl/rf//iYI9eFC3BkojGepsfPHBQhPAf2pWSxlff40b6AvQv15B1OpVR6s5SLcuNbOTMHyJZr0g82yUJfKhkE8q4eNgTckW8imgQRYJ2uD/53xLdR7btEGshHWoCckPfFP6JHNBUDwTHiVoTFXTJjc2JkBkLfknigOgMZLC7N1gYM6ounVVl+RBiywgAs0gw7obwczKOnI5KWTTSSwE/99d/NWhrQzCcKrhcMkW7ub10uqJoZzS6TvwBWC3l7O+b8QFW73vlb/D8KHw0I9D9FGIX2xOd7Rz5vFQv0cP75fH3NtGYtF20J+avS9HDIVxDraMud1JsutDarlXqyEZM3iQMnJYsn1QeL1XtjNoSE4wrI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zhFyx3vfYBkAKbgQ7lwiF2tD9HgBfT6RmIbhBckXbnBX71qsZxgyL0gpZrUxN0WbJO0w1WdZAZVfTixMRmJJmK2n7910WukVbvz0rHLC2LY15+nyw42owoC1L17t",
"com.salesforce.visualforce.ViewStateMAC":"AGV5SnViMjVqWlNJNklsaE1PVFJIVTI5UVNFZ3lhMWhFZHpKNk1qbDRZemQyTjFNeGNXUjFPR3hOTlU5M2MzaGxRMGxXZFc5Y2RUQXdNMlFpTENKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUlzSW10cFpDSTZJbnRjSW5SY0lqcGNJakF3UkVNd01EQXdNREF3VUdoMVVGd2lMRndpZGx3aU9sd2lNREF3TURBd01EQXdNREF3TURBd1hDSXNYQ0poWENJNlhDSjJabk5wWjI1cGJtZHJaWGxjSWl4Y0luVmNJanBjSWpBd05VTXdNREF3TURBeldWcEZkRndpZlNJc0ltTnlhWFFpT2xzaWFXRjBJbDBzSW1saGRDSTZNVFE1TlRFM05Ua3pNelEyTXl3aVpYaHdJam93ZlE9PS4uejVLNUJMeGJ0WDVIX2ZQelI4bTZBZFhTNFk2MDNFODFqUkpkTUFqN29GRT0=",
"passportTrackerPage:psptTrackerForm:trackButton":"passportTrackerPage:psptTrackerForm:trackButton"
}
rep = requests.post("http://cgifederal.force.com/passporttracker", data=data)
soup = BeautifulSoup(rep.text,"lxml")
re = soup.find_all(class_="result")[0].string nowTime = time.strftime('%Y-%m-%d %H:%M:%S')
while nowTime == beforeTime:
nowTime = time.strftime('%Y-%m-%d %H:%M:%S')
time.sleep(sleepTime) beforeTime = nowTime os.system('clear')
print nowTime
print passportNo+'\'s','result:',re # raw_input(unicode('按回车键查询护照最新状态↩ ','utf-8').encode('utf-8'))