-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcheckUSCIS.py
70 lines (60 loc) · 2.72 KB
/
checkUSCIS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import requests
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup as bs
import sys
import random
import re
import argparse
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def PollNeighbours(prefix,CaseNum,neighbours=10,processingStr="we received your Form I-765"):
processingCount=0
CaseNumIter=CaseNum-int(neighbours/2)
for i in range(neighbours):
CaseNumIter+=1
if(CaseNumIter != CaseNum):
print(bcolors.OKBLUE+"checking USCIS for Reciept: "+prefix+str(CaseNumIter)+bcolors.ENDC)
if processingStr in requestStatus(prefix+str(CaseNumIter)):
processingCount+=1
print(bcolors.BOLD+str(processingCount)+" out of "+str(neighbours)+" filed around your file date are still pending, don't give up!"+bcolors.ENDC+"\n")
# print("")
#changeLocale=&completedActionsCurrentPage=0&upcomingActionsCurrentPage=0&appReceiptNum=YSC1990011345&caseStatusSearchBtn=CHECK+STATUS
def requestStatus(caseID):
#
formData={"changeLocale":None,"completedActionsCurrentPage":0,"upcomingActionsCurrentPage":0,"appReceiptNum":caseID,"caseStatusSearchBtn":"CHECK STATUS"}
response = requests.post('https://egov.uscis.gov/casestatus/mycasestatus.do',data=formData)
soup=bs(response.content, "html.parser" )
msg=soup.select("div form div div div div div div.rows.text-center p")[0].get_text()
#print(bcolors.BOLD++bcolors.ENDC+"\n")
return msg
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('Reciept Number',
help='Your USCIS Reciept Number, starts with 3 letters',
default='')
parser.add_argument('-n', type=int,metavar='N',nargs='?', const=10 ,help='Enable Neighbour Polling, followed by # of neighbour to check, default is 10')
args = parser.parse_args()
# print(vars(args)['Reciept Number'])
# print(args.n)
#CaseNum=sys.argv[1]#1990011345 - int(neighbours/2) #
CaseNum=vars(args)['Reciept Number']
#try:
match = re.match(r"([a-z|A-Z]+)([0-9]+)", CaseNum, re.I)
prefix = match.groups()[0]
CaseNum = int(match.groups()[1])
print("Case entered:",prefix , CaseNum)
if(args.n is None):
msg=requestStatus(prefix+str(CaseNum))
print(bcolors.OKGREEN+"USCIS Says"+bcolors.ENDC)
print(bcolors.BOLD+msg+bcolors.ENDC)
else:
PollNeighbours(prefix,CaseNum,neighbours=args.n,processingStr="we received your Form I-765")
# except:
# print("ERROR, Case number format incorrect, should start with 3 letters followed by digits")