Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
  • Does word press coding effects in search engines?? (In: Coding & Databases - PHP, ASP, Perl, etc.)
  • Are small sellers penalized by search engines? (In: General Search Engine Optimization)
  • Torrent search engine 4sale! (In: I Want to Sell My Website)
  • Featured Web Site Template

    Hundreds More at Free Site Templates.com!

    Web Site Partners
    Sponsored Links
    Jet City Software
     
    Whos Here ?
    Reflects user activity within the last 5 minutes
    Moderator(s): Prowler, jcokos
    Member Message

    k0106932
    Joined: Jan 20, 2005
    # Posts: 1

    View the profile for k0106932 Send k0106932 a private message

    Posted: 2005-Jan-21 06:06
    Edit Message Delete Message Reply to this message

    Hello all,

    I am very new to CGI scripting and perl. I have managed to create a perl program which searches through the URL that I have specified and extracts all of the URL's to a a specific extraction level which is chosen by the user. What I would like to do, is incorporate CGI into this Perl code, Specifically that the user is presented with a html page, with a simple submit button on, which then executes the Perl code, which runs the script and then displays all of the results on another HTML page. Please find included the code which I have prepared.

    Any help would be greatly appreciated.

    Kind Regards

    Peter

    #!usr/bin/perl

    use LWP::Simple;

    $url = "http://www.kingston.ac.uk";
    $content = "Kingston University";
    $level = 2;
    $regexp = "<a\s+.*?href\s*=\s*"(http://.*?)".*?>(.*?)</a>";

    $store[0] = $content;
    $store[1] = $url;
    $oldstoresize = 0;

    for ($levelcounter=0; $levelcounter<=$level; $levelcounter++){
    $newstoresize = @store;
    for ($oldstoresize; $oldstoresize<$newstoresize; $oldstoresize+=2){
    $temppage=get($store[$oldstoresize+1]) or die("Couldn't get page"wink;
    while ($temppage=~/$regexp/sig){
    push (@store,$2,$1);
    }
    }
    $oldstoresize = $newstoresize;
    }
    foreach (@store){
    print $_."n";
    }
    $filename = "data.txt"; open(File1,">$filename"wink;
    for($i=0;$i<@store;$i+=2){
    print File1 $store[$i]." ".$store[$i+1]."n";
    }



    Prowler
    Staff
    Joined: Aug 14, 2000
    # Posts: 1832

    View the profile for Prowler Send Prowler a private message

    Posted: 2005-Jan-24 12:35
    Edit Message Delete Message Reply to this message

    There are many ways you can do ( as they say in Perl motto - There is more than one way to do it) this.

    Put up a simple HTML page with the form value as given below:
    <form method="POST" action="http://www.your-server/cgi-bin/kingston.cgi">
    URL http://<input type="text" size="50" name="url">
    <input type="submit" value="Check"></form>

    This HTML page will call your kingston CGI script which can probably run like this: (after the usual shebang etc)

    use LWP 5.64;

    my $browser = LWP::UserAgent->new;
    $browser->agent(
    'Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC)' );
    # Mimic Some normal Browser



    print "Content-type: text/htmlnn";
    print <<endo;
    <html><head><title>

    <!--Whatever you like to have here -- >

    endo

    my $response = $browser->get($url);
    #die "Can't get $url -- ", $response->status_line



    print "<b>",$response->status_line,"</b><br>n" ;
    if ($response->is_success) {
    print "Starting ...<br>n";
    my $html = $response->content;
    while( $html =~ m/<A HREF="(.*?)"/ig ) {
    print URI->new_abs( $1, $response->base ) ,"<br>";
    $count++;
    }
    }

    ----------------------
    I am using slightly different method to parse the HTML page and extract the URL.

    All the above are intended to point you to the right direction. smile


    You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
    1. You have not yet logged in, or registered properly as a member
    2. You are a member, but no longer have posting rights.
    3. This is a private forum, for which you do not have permissions.

    If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

    If you cannot find this message, click here to Re-Send it.

    If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

    Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

    New posts Forum is locked
    © 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions