Any perl gurus....

ihack1

Registered Users (C)
Tried to write a hack for online status check with LWP module ? POST doesn't seem to work well with jsp.
 
Thanks a lot!

alsowaiting,
Thanks a lot for your quick response. I didn't see that thread before... I will check it out....
 
ihack1

Use LWP, but also make sure you have a HTTPS package such as Crypt::SSLeay. Also the website needs to set a cookie and therefore use HTTP::Cookies package as well.
 
Re: ihack1

Originally posted by poongunranar
Use LWP, but also make sure you have a HTTPS package such as Crypt::SSLeay. Also the website needs to set a cookie and therefore use HTTP::Cookies package as well.

You continue to amaze me with your wide variety and in depth knowledge. I installed Crypt::SSLeay. However, I had issues with parameters for the cookie settings.... I will go through the perl program. Feel like a kid in a candy store :) Once, I get this working, probably, setup DBI/DBD with Oracle, upload search data, query by all sorts, setup Tk, put some GUI face....etc.. etc...
 
only a perl novice, but...

Hi Folks,

Details are:

PD: sometime in 1998
RD/ND: Nov '01 (SRC020415XXXX)
FP: May '03
3 EAD's; waiting for 3'rd AP

Attached is a perl script that does something along the lines of the excel spreadsheet (prefer using this to the spreadsheet).

Invoke as:

caseStat.pl -f <input_file_name>

Input file contains a list of case status numbers. The script writes out an output file: "case_status_results.txt" that contains the information:
CaseNo, Appl. Type, Status, Date (just like the spreadsheet).
If you rename the outputfile and use it as an input file, that will also work (since we read the first field in each record of the input file to obtain case status results).

I will upload a sample output/input for SRC020415XXXX that I collected through this script.

Thanks.
Sam

-------------------------
Folks - I have edited this posting and removed the earlier attachment. Please download the script from my later posting below. Thanks and apologize for the inconvenience.
-------------------------
 
Last edited by a moderator:
ihack1

Friend, I wrote this program and have been using this for a loooooong time now. If you want some jazzy emailing stuff, etc., all you need is to invoke one of the Email modules of Perl (Net::SMTP, Mail::Sender, etc.)

Try this code, friend. It works like a charm.

#Author: 'Poongunranar'
#From Command-line invoke this program with a SINGLE command-line argument, viz. your SRC number without any dashes
#Example: perl <scriptname> SRC0122244444
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TokeParser;
my($array) = [];
my $agent = WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new);
$agent->get("https://egov.immigration.gov/graphics/cris/jsps/caseStat.jsp");
$agent->form(1);
$agent->field("appReceiptNum", "$ARGV[0]");
$agent->click();
my($stream) = HTML::TokeParser->new(\$agent->{content});
#my($stream) = HTML::TokeParser->new("C:/bcis.htm");
$stream->get_tag("table") for(1..5);
$stream->get_tag("tr");
my $td = $stream->get_tag("td");
print $stream->get_trimmed_text("/b"),"\n"; #Case #
$stream->get_tag("p");
print $stream->get_trimmed_text("/b"),"\n"; #App Type
$stream->get_tag("p");
print $stream->get_trimmed_text("/b"); #Current Status
$stream->get_tag("p");
print $stream->get_trimmed_text("/p"),"\n\n\n"; #Actual Status
 
Re: ihack1

Originally posted by poongunranar
Friend, I wrote this program and have been using this for a loooooong time now. If you want some jazzy emailing stuff, etc., all you need is to invoke one of the Email modules of Perl (Net::SMTP, Mail::Sender, etc.)

Try this code, friend. It works like a charm.

#Author: 'Poongunranar'
#From Command-line invoke this program with a SINGLE command-line argument, viz. your SRC number without any dashes
#Example: perl <scriptname> SRC0122244444
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TokeParser;
my($array) = [];
my $agent = WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new);
$agent->get("https://egov.immigration.gov/graphics/cris/jsps/caseStat.jsp");
$agent->form(1);
$agent->field("appReceiptNum", "$ARGV[0]");
$agent->click();
my($stream) = HTML::TokeParser->new(\$agent->{content});
#my($stream) = HTML::TokeParser->new("C:/bcis.htm");
$stream->get_tag("table") for(1..5);
$stream->get_tag("tr");
my $td = $stream->get_tag("td");
print $stream->get_trimmed_text("/b"),"\n"; #Case #
$stream->get_tag("p");
print $stream->get_trimmed_text("/b"),"\n"; #App Type
$stream->get_tag("p");
print $stream->get_trimmed_text("/b"); #Current Status
$stream->get_tag("p");
print $stream->get_trimmed_text("/p"),"\n\n\n"; #Actual Status
poongunranar,
Thank you! Its neat and simple. I was trying to POST not knowing click() sub. Works great!
Learning perl in addition to immigration stuff... Thanks again.
 
Re: only a perl novice, but...

Originally posted by samXadams
Hi Folks,

Details are:

PD: sometime in 1998
RD/ND: Nov '01 (SRC020415XXXX)
FP: May '03
3 EAD's; waiting for 3'rd AP

Attached is a perl script that does something along the lines of the excel spreadsheet (prefer using this to the spreadsheet).

Invoke as:

caseStat.pl -f <input_file_name>

Input file contains a list of case status numbers. The script writes out an output file: "case_status_results.txt" that contains the information:
CaseNo, Appl. Type, Status, Date (just like the spreadsheet).
If you rename the outputfile and use it as an input file, that will also work (since we read the first field in each record of the input file to obtain case status results).

I will upload a sample output/input for SRC020415XXXX that I collected through this script.

Thanks.
Sam

samXadams,
Thanks for the posting your code.

ihack1
 
If anybody is interesed in using VB6 for this, let me know. I wrote an exe for this using webbrowser control.
 
Originally posted by losthope
Where do you get the perl module WWW::Mechanize. I'm using active perl and can't find it.

Thanks

In PPM, do a search for Mechanize and then install, Below is the screen capture :


PPM - Programmer's Package Manager version 3.0.1.
Copyright (c) 2001 ActiveState SRL. All Rights Reserved.

Entering interactive shell. Using Term::ReadLine::Stub as readline library.

Profile tracking is not enabled. If you save and restore profiles manually,
your profile may be out of sync with your computer. See 'help profile' for
more information.

Type 'help' to get started.

ppm> search mechanize
Searching in Active Repositories
1. WWW-Mechanize [0.48] automate interaction with websites
2. WWW-Mechanize [0.35] (none)
3. WWW-Mechanize [0.40] (none)
4. WWW-Mechanize [0.43] (none)
5. WWW-Mechanize [0.44] (none)
6. WWW-Mechanize [0.48] (none)
7. WWW-Mechanize-FormFiller [0.05] framework to automate HTML forms
ppm>
 
Re: Re: only a perl novice, but...

Originally posted by ihack1
samXadams,
Thanks for the posting your code.

ihack1

Hi ihack1,

Thanks. I have another feature in an updated version of the script (old one had a bug for this). This will allow collecting statistics like the excel spreadsheet.

Usage example:

caseStat.pl -c SRC030015

will try to get results of all cases from SRC0300150001 to SRC0300159999. Results are written to "case_status_results.txt".

If such a file already exists, then the script will continue from where the previous run left off (will not enquire about existing records in the results file).

The problem is that after a certain number of queries, http requests from the machine are blocked. Removing the cookies file is not enough to overcome this. So, I run on different machines and over a few days, can colled all valid SRC numbers of a certain day. Then I can filter out I485 or I131 or any other case and then run the script as:

caseStat.pl -f <input file> to get updates on these cases.

Regards.
-Sam
 
Top