tonyday has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to learn about all things webby, in particular LWP::UserAgent and HTML::Parser. I need help though as I find that my attempts at meaningful functionality are being frustrated by Javascript. Before I explain my problem, I would like to state that I am starting with zero net knowledge eg I have never used cgi, coded javascript or designed a web page say. Ok, so let me explain what's happening with an example...
The Project
As a learning project, I decided to try and write some code that would perform the following actions:
1. log on to my net banking site,
2. locate my account balances and recent transactions,
3. reconcile these with my budget and personal records, and finally
4. send a chatty email to my wife based on the results thus proving to her that my interest in perl can lead to practical benefits.
Initial Problem
I haven't been able to get past step 1. Firstly, I learnt about lwp and html via the pods and some basic code to be able to get pages and extract html. The future seemed bright and clear. Then I tried to apply this knowledge to the project. The first thing I noticed was that the start page was javascript. No matter, I'll just scan the source and extract what I need.
I then plugged the refernced url into my code and got the following...
META HTTP-EQUIV="Pragma" CONTENT="no-cache" META HTTP-EQUIV="REFRESH" REFRESH: 0; CONTENT="0; URL=https://www.xxxb +ank.com//main.htm"
Looking good... so after finding out about what https stands for I was ready. Alas, all I got for my trouble was a 500: Unknown Error error. Here is my modest code pretty much equal to the pod example.
my $start_page = 'https://www.xxxbank.com//main.htm'; use LWP::UserAgent; use HTTP::Cookies; $ua = LWP::UserAgent->new; $ua->agent("Mozilla/8.0"); # pretend we are very capable browser $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1)); $req = HTTP::Request->new(GET => $start_page); $res = $ua->request($req); print "Error: " . $res->status_line . "\n" unless $res->is_success; print $res->content;
The Question
I'm not sure where to go now. I have tried going to the next stage of the login where I found form data that I put in a POST request but it led to the same error. My feel is that pages with lots of Javascript are inaccessible to a humble perl hacker and will end in tears. Is the wide world out there a Java one or can someone counsel perl perseverence and eventual enlightenment. I'm happy to do the hard yards of understanding html, cgi and so on but I get a chill in my spine thinking about hacking through javascript.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(crazyinsomniac: strategy) Re: LWP and Javascript
by crazyinsomniac (Prior) on Feb 07, 2002 at 08:45 UTC | |
|
Re: LWP and Javascript
by gav^ (Curate) on Feb 07, 2002 at 05:31 UTC | |
by tonyday (Scribe) on Feb 07, 2002 at 05:44 UTC | |
|
Re: LWP and Javascript
by dws (Chancellor) on Feb 07, 2002 at 06:37 UTC | |
by Dog and Pony (Priest) on Feb 08, 2002 at 12:45 UTC | |
|
Re: LWP and Javascript
by screamingeagle (Curate) on Feb 07, 2002 at 06:33 UTC |