the part of the prog is:
var rawfile = key.txt (THIS WILL BE THE HTML SOURCE TXT FILE)
get url [berny.com...]
var 2wayproc = perl key.pl (THIS WOULD BE THE SCRIPT TO FIND THE HIDDEN VALUE)
subst KEY6 2wayread
field pass_id = 213453
field msg_id = 2666295
field key5 = 4
field 11 = $$KEY6$$ (THIS WOULD BE THE KEY I NEED)
var Referer = [berny.com...]
post url [berny.com...]
print a msg foi impressa
thanks , i really need this help...i tried everything but i could not make it work...it seems to be a simple script to get a value from a txt file...
I´m not quite sure whether you want to get the value you are after over the net or directly from a file sitting on your server.
If the former is the case then the hidden form fields will be transmitted to the server when the form is submitted by the client. You can access them just like you access any other form field.
If you want to search the text file locally then you need to open the file, search for the line you need and close the file after that. If you want to extract the value from an HTML document you might want to use HTML::Parser if your docs are rather complex since a simple RE approach may fail on certain HTML constructs.
To give you more specific advise you would need to explain what you are after a bit more clearly.
Andreas
<body>
.....
.....
<input type="hidden" value='6291587' name='class_id'>
<input type="hidden" value='4' name='key5'>
<input type="hidden" value='EF3854' name='11'>
So the script would open the file sarch print and them close......
use HTML::Parser;
use LWP::UserAgent;
#
my $p = HTML::Parser->new(
api_version => 3,
start_h => [sub {
return unless pop eq 'input';
my $attr = pop;
return unless $attr->{type} eq 'hidden';
my $self = shift;
$self->{__my_secret_value__} = $attr->{11};
$self->eof;
}, 'self, attr, tagname'],
);
#
my $ua = new LWP::UserAgent;
#
{my $res = $ua->request(
HTTP::Request->new(GET => $url),
sub {last unless $p->parse($_[0])});}
#
print $p->{__my_secret_value__};
If you want to use RE this should work:
$text =~ /<input type=(["'])hidden\1 value=(["'])([^\1]+)\1 name=(["'])11\4>/;
$__my_secret_value__ = $3;
# Unbuffer STDOUT
$¦ = 1;
open FILE,'msgs.txt' ¦¦ die "Não achei o arquivo com as classes...\n";
@listademsgs = ();
while (<FILE>) {
if (s/(\/Scripts\/CLASSD.asp\?group=&kkey=&ID=)(\d\d\d\d\d\d\d)/$2/) {
push (@listademsgs,$2);
}
}
while (<>) {
print "$listademsgs[$_]\n";
}
close FILE;
_________________________________________________
it shows the msgs number(Id)...and prints it to the prog, so it can use it.....
the MSGS.TXT has the following in it:
part of it is
<B><pre>MSG will be run 12/29/2002</pre>
</pre>
<center><img src="/wsdocs/cyber/PR_BAR.gif" border="0" align="middle"></center>
<a href="/Scripts/CLASSD.asp?group=&kkey=&ID=6352070"> (6352070) </a><br>
<a href="/Scripts/CLASSD.asp?group=&kkey=&ID=6352075"> more classes in about 20 min. (6352075) </a><br>
<center><img src="/wsdocs/cyber/PR_BAR.gif" border="0" align="middle"></center>
<p><font size="2">Record ID=170641
</form></body></html>
</body>
</html>
So you can have an idea of what i need...
I need a script that reads the key.txt that has the
<input type="hidden" value='6291587' name='class_id'>
<input type="hidden" value='4' name='key5'>
<input type="hidden" value='EF3854' name='11'>
</font></form>
</body></html>
and prints out the EF3854 (only without '')....
OBS that value changes all the time...
Could it be possible for you to give me an ex: of the script above with what you gave me...?
while (<FILE>) {
if (s/(\/Scripts\/CLASSD.asp\?group=&kkey=&ID=)(\d\d\d\d\d\d\d)/$2/) {
push (@listademsgs,$2);
}
if (/<input type="hidden" value='([^']+)' name='11'>/) {
print "your secret value is: $1\n";
}
}
The re will look for a string that starts with <input type="hidden" value=' followed by one or more (i.e. the plus sign) characters that are not ' followed by ' name='11'>.
Hope this helps.
Andreas
i found the following code in the WWW...maybe it can be usefull, i tried but did not work :
..................
#!/usr/bin/perl
open(F, "<" . $ARGV[0]) or die "Could not open " . $ARGV[0] . ": " . $! . "\n";
undef $/;
my $file = <F>;
close(F);
my $last = "";
while($file =~ m/<input type="hidden" value="(.*?)" name=(.*?)>/isg) {
$last = $1;
}
print $last;
.................
Thanks again, i will try the script you gave me