Created
June 26, 2015 04:14
-
-
Save zhangyoufu/8b718eaebf19b264cea5 to your computer and use it in GitHub Desktop.
Check US Visa Status
This file contains 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
import re | |
import requests | |
import sys | |
if len(sys.argv) != 2: | |
print 'Usage: python niv.py <Case Number (AAxxxxxxxx)>' | |
exit() | |
url = 'https://ceac.state.gov/CEACStatTracker/Status.aspx?App=NIV' | |
extract = lambda pattern: ( re.search( pattern, resp.content ) or re.match('()','') ).group(1) | |
session = requests.session() | |
resp = session.get( url ) | |
data = { k: extract( 'id="%s" value="([^"]+)' % k ) for k in ['__VIEWSTATE', '__EVENTVALIDATION'] } | |
data.update({ | |
'__EVENTTARGET': 'ctl00$ContentPlaceHolder1$btnSubmit', | |
'ctl00$ContentPlaceHolder1$txbCase': sys.argv[1], | |
}) | |
resp = session.post( url, data=data ) | |
for k in ['lblStatus', 'lblSubmitDate', 'lblStatusDate', 'lblResponseDate']: | |
value = extract( '%s">([^<]+)' % k ) | |
if value: | |
print '%-13s: %s' % ( k[3:], value ) |
This file contains 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
import re | |
import requests | |
import sys | |
if len(sys.argv) != 2: | |
print 'Usage: python passport.py <Passport Number>' | |
exit() | |
url = 'http://cgifederal.force.com/passporttracker?country=China&language=zh_CN' | |
extract = lambda pattern: re.search( pattern, resp.content ).group(1) | |
session = requests.session() | |
resp = session.get( url ) | |
data = { k: extract( 'name="%s" value="([^"]+)' % k ) for k in ['com.salesforce.visualforce.ViewState', 'com.salesforce.visualforce.ViewStateVersion', 'com.salesforce.visualforce.ViewStateMAC'] } | |
data.update({ | |
'AJAXREQUEST': '_viewRoot', | |
'passportTrackerPage:psptTrackerForm': 'passportTrackerPage:psptTrackerForm', | |
'passportTrackerPage:psptTrackerForm:trackButton': 'passportTrackerPage:psptTrackerForm:trackButton', | |
'passportTrackerPage:psptTrackerForm:j_id34:j_id35:passportNo': sys.argv[1], | |
}) | |
resp = session.post( url, data=data ) | |
print extract( 'result">([^<]+)' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment