Please help to modify this perl script. I need to add more urls

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

Please help to modify this perl script. I need to add more urls

 
0
  #1
May 29th, 2005
I need to modify this script to have also an external txt file with urls instead of having only one url from the form that is created by the script. Just like the proxy.txt and agents.txt.
Please help me...

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();
}
sub newinfo{
print <<ENDHTML;
<form action=bot.cgi?hitsnow method=post>
URL to send hits to:<input type=text name=url><br>
Refferring URL:<input type=text name=refer><br>
How many hits to send:<input type=text name=howmany><br>
<input type=submit value=Submit></form>
ENDHTML
;
exit;
}
if ($buffer eq 'hitsnow'){
&sendthemhits();
}
sub sendthemhits{
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
for($count=1;$count<$FORM{howmany};$count++){
open(QQ,"$proxy");
@proxies=<QQ>;
close(QQ);
open(WE,"$agents");
@agents=<WE>;
close(WE);
srand;
@run = (0..$number);
$run = rand(@run);
@ug = (0..$nagent);
$ug = rand(@ug);
my $ua = LWP::UserAgent->new(agent => "@agents[$ug[$ug]]" , keep_alive => 1 , timeout => 10);
$ua->proxy('http',"http://@proxies[$run[$run]]");
my $res = HTTP::Request->new( GET => "$FORM{url}");
$res->referer("$FORM{refer}");
my $response= $ua->request($res);
if ($response->is_success){
print "Connection: $count - @proxies[$run[$run]] - Success<br>\n";
}
}
}
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Please help to modify this perl script. I need to add more urls

 
0
  #2
May 30th, 2005
I'm not 100% sure that I understand what you are asking. I know that you want to use a text file to be read into the script, but what I'm lost at, is are you wanting for the HTML that accepts the URL and number of hits to no longer exist, and have that information be replaced by the text file?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

Re: Please help to modify this perl script. I need to add more urls

 
0
  #3
May 30th, 2005
Originally Posted by Comatose
I'm not 100% sure that I understand what you are asking. I know that you want to use a text file to be read into the script, but what I'm lost at, is are you wanting for the HTML that accepts the URL and number of hits to no longer exist, and have that information be replaced by the text file?

Hello,

Yes that's exactly what I want. Cause I would like better to call this script by cron and have set all those variables in txt files so the script would work when it's called by cron and not when I call it from the browser as it works now.

Thanks for your help and time.

James
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Please help to modify this perl script. I need to add more urls

 
0
  #4
Jun 4th, 2005
Ok, The information that the web page retrieves, I need to know what kind of file format they are in. I understand they will be text, but I need to know the format of it, such as:

  1. url <TAB> referer <TAB> howmany

or will it be something like:
  1. url
  2. referer
  3. howmany

or will they be in different text files, or how is this supposed to work. I can modify the script to work with the text files, but I need to understand how you will have it laid out. Let me know.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

Re: Please help to modify this perl script. I need to add more urls

 
0
  #5
Jun 6th, 2005
Hi,

They'll be in different text files. One URL per line. The "how many hits will be just a number in a txt file let's say for 30 hits per url (i.e. 30).
I need it to run from cron.

Now(the way the script works) I need to call the script http://myurl.com/test.cgi?new to run the script and it waits for user input. I want to be able to upload the txt files and set the script to work lets say every night at 12:00 with a cron command.



Look the start of this code:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
####Proxy addresses#####
$proxy="proxy.txt";
####How many proxies are in this file####
$number='350';
##################################################DO NOT EDIT BELOW THIS LINE!#############################
print "Content-type: text/html\n\n";
$agents="agents.txt";
$nagents='21';
$buffer = $ENV{'QUERY_STRING'};
if ($buffer eq 'new'){
&newinfo();


Thanks

James
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 5128 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Perl
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC