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