Using OPEN and LWP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pplers
    New Member
    • Apr 2007
    • 60

    Using OPEN and LWP

    i wanted a script to check whether a premium account is still working or not, so i tried these:

    Code:
    use LWP::Simple;
    
    open (IN, 'accounts.txt');
    while (<IN>) {
    	chomp;
    
    	$user=substr($_,0,5);
    	$pass=substr($_,6,6);
    
    	print "\n";
    
    	while () {
    		sleep(3);
    
    		my $rap = get("https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?login="."$user"."&password="."$pass");
    
    		if ($rap=~/Account found, but password is incorrect./) {
    			print "Password incorrect";
    		} elseif($rap=~/Account not found/) {
    			print "Account not found";
    		}
    	}
    }
    close (IN);
    and the file accounts.txt is something like:

    Code:
    11111:222222
    11111:222222
    11111:222222
    11111:222222
    11111:222222
    11111:222222
    11111:222222
    11111:222222
    but the script doesn't work, can anyone help me a bit ...... thanks
    Last edited by miller; Apr 30 '07, 02:00 AM. Reason: Reformatted Code
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    "Doesn't work" is very vague. What does it do?

    Comment

    • pplers
      New Member
      • Apr 2007
      • 60

      #3
      it only prints the "\n" (line skip) and stays there, it doesn't check with rs.com


      try it


      p.s: i know that elseif($rap=~/Account not found/) should be elsif($rap=~/Account not found/) but when i couldn't edit my post

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        take out the embedded while() loop and see if that helps.

        remove these lines:

        Code:
        while()
        {
        
        
        }

        Comment

        • pplers
          New Member
          • Apr 2007
          • 60

          #5
          yeah, i already did but still doesn't work

          have you tried it ?

          Comment

          • pplers
            New Member
            • Apr 2007
            • 60

            #6
            sorry for the double post..

            i did perl script.pl > outtext.txt (in windows) and i realized that the problem is in the regular expresion

            i tried a new script to that, i only did one request,

            Code:
            use LWP::UserAgent;
            
            my $ua = LWP::UserAgent->new;
            my $req = HTTP::Request->new(GET => 'https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?login=22154&password=233424');
            my $res = $ua->request($req);
            
            if ($res=~/<\/script>Account found, but password is incorrect.<\/p>/)
            {
            print "Password incorrect";
            }
            elsif($res=~/Account not found/)
            {
            print "Account not found";
            }
            else{
            print $res->as_string;
            }
            the result should say: Password incorrect

            i don't know whats wrong in the regexp

            Comment

            • pplers
              New Member
              • Apr 2007
              • 60

              #7
              i fixed it....
              it wasn't the regexp

              Code:
              use LWP::UserAgent;
              
              my $ua = LWP::UserAgent->new;
              my $req = HTTP::Request->new(GET => 'https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?login=22154&password=233424');
              my $res = $ua->request($req);
              my $ris = $res->as_string;
              
              if ($ris=~/<\/script>Account found, but password is incorrect.<\/p>/)
              {
              print "Password incorrect";
              }
              elsif($ris=~/Account not found/)
              {
              print "Account not found";
              }
              else{
              print $ris;
              }
              the only preoblem i have when adjusting the changes to the original script (first posted) is that the part when the script has to open the file and extract the info, it doesn't work

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                see what this returns:

                Code:
                open (IN, 'accounts.txt') or die "Can't open accounts.txt: $!";

                Comment

                • pplers
                  New Member
                  • Apr 2007
                  • 60

                  #9
                  thanks, i turn it into a function and now it works:

                  Code:
                  use LWP::UserAgent;
                  
                  open (IN, 'accounts.txt') or die "Can't open accounts.txt: $!";
                  while (<IN>) {
                   chomp;
                    $user=substr($_,0,5);
                    $pass=substr($_,6,6);
                  
                  &check($user,$pass);
                  
                  }
                  close (IN);
                  
                  
                  sub check{
                  my $user = shift;
                  my $pass = shift;
                  
                  my $ua = LWP::UserAgent->new;
                  my $req = HTTP::Request->new(GET => "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?login="."$user"."&password="."$pass");
                  my $res = $ua->request($req);
                  my $ris = $res->as_string;
                  
                  if ($ris=~/Account found, but password is incorrect/)
                  {
                  print "Password incorrect\n";
                  }
                  elsif($ris=~/Account not found/)
                  {
                  print "Account not found\n";
                  }
                  else{
                  print "Script Error\n";
                  }
                  }
                  Last edited by pplers; Apr 30 '07, 01:19 PM. Reason: mistake

                  Comment

                  Working...