954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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... :confused:

#!/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 <
URL to send hits to:

Refferring URL:

How many hits to send:

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=;
close(QQ);
open(WE,"$agents");
@agents=;
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
\n";
}
}
}

classifieds100
Newbie Poster
5 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

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?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 
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

classifieds100
Newbie Poster
5 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

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:

url <TAB> referer <TAB> howmany


or will it be something like:

url
referer
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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

classifieds100
Newbie Poster
5 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You