Skip to content

Instantly share code, notes, and snippets.

@prakhar1989
Created December 16, 2016 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prakhar1989/e0eb27b8d6c8df23a23383f4a0cab0a9 to your computer and use it in GitHub Desktop.
Save prakhar1989/e0eb27b8d6c8df23a23383f4a0cab0a9 to your computer and use it in GitHub Desktop.
OPT status check
/**
* 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");
}
});
@tugcekeser
Copy link

tugcekeser commented Jun 1, 2017

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment