User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 402,922 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,059 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 4092 | Replies: 4
Reply
Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

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

  #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";
}
}
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

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

  #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  
Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

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

  #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  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

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

  #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:

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.
Reply With Quote  
Join Date: May 2005
Posts: 5
Reputation: classifieds100 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
classifieds100 classifieds100 is offline Offline
Newbie Poster

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

  #5  
Jun 5th, 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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 4:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC