Created
December 16, 2016 21:53
-
-
Save prakhar1989/e0eb27b8d6c8df23a23383f4a0cab0a9 to your computer and use it in GitHub Desktop.
OPT status check
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
/** | |
* npm install superagent cheerio | |
* node index.js <your_case_number> | |
*/ | |
const request = require('superagent'); | |
const cheerio = require('cheerio'); | |
const URL = "https://egov.uscis.gov/casestatus/mycasestatus.do"; | |
const receipt = process.argv[2]; | |
request.post(URL) | |
.type('form') | |
.send({ | |
appReceiptNum: receipt, | |
initCaseSearch: 'CHECK STATUS', | |
changeLocale: '' | |
}) | |
.end(function(err, res) { | |
if (res.statusCode == 200) { | |
let $ = cheerio.load(res.text); | |
let h1= $('.appointment-sec h1'); | |
let msg = $('.appointment-sec p'); | |
console.log(h1.text()); | |
console.log(msg.text()); | |
} else { | |
console.log("error: unable to read resp"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I just wanted to let you know this code gives "TypeError: Cannot read property 'statusCode' of undefined" error for some receipt numbers. When I changed the line 19 and make it "if (!err && res.statusCode == 200) {" , it solved this error in the code.
Thanks for sharing,