I subscribe to online books, and I want to fetch my books and put them to a file. I've been researching for weeks, reading posts and pods, mans and libs.

I don't want to use tk 'cause I'm not that savy. I know what I need is in LWP::UserAgent, Open::SSLeay, HTTP::Request, Get::Opt and more.

I'm new to programming and my code snippet is laughable, but I am trying. And incomplete, I realize I need serious direction.

I'm stuck on the secure https authentication, I haven't been able to get past the asp form, even after installing and reading the secure socket module. Then I need to get to my book and fetch it to one file, recursively finding all pages (which are links), or should I use an array? I don't know how to piece it together, and because there's more than one way to write perl, I'm half delirious.

I'm open for any suggestions, advice and criticism.
use strict; use LWP::UserAgent; use Open::SSLeay; use HTTP::Request::Common; # ASP FORM SOURCE CODE # <form name=login method=post action="mainin.asp"> # <font size="2">E-Mail Address :</font> # <input type=text name="login" size=20 maxlength=60 value="" class +=inputtext> # # <font size="2">Password :</font> # <input type="password" name="passwd" size=20 maxlength=60 class=i +nputtext> # <input type="submit" name="action" value="Log In" class="inputbutton +"> # </form> # I NEED TO LOGIN my $ua = LWP::UserAgent->new; my $ua->request(POST 'https://domain/sec/mainin.asp?login', [login = +> foo@bar.com, passwd => snafu]); # HOW DO I RECURSIVELY FIND ALL LINKS, OR USE AN ARRAY? # ANY ADVICE ON WHERE TO START TO WRITE THIS CODE? @PAGE = # HOW ABOUT MORE THAN ONE BOOK - I HAVEN'T A CLUE. @BOOK = # AFTER LOGIN SUCCESS, I NEED TO 'GET' THE BOOK, APPENDING EACH PAGE T +O FILE FETCHEDBOOK.TXT my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => 'http://domain/main.asp?bookname +=@BOOK&page=@PAGE'); my $res = $ua->request($req,>>"FETCHEDBOOK.TXT"); if ($res->is_success) { print $res->FETCHEDBOOK.TXT; } else { print "Failed: ", $res->status_line, "\n"; }
Many thanks in advance.

In reply to Fetch html to a file by Gnuser

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.