naco
asked on
Need Help on Script to read a hidden value
Hello, i have a program developed in perl but i need a script to make the program find a hidden value in a html text document.
Ex:
<body>
.......
<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>
it would read the txt with the html source code and show the third line value.. for ex: print EF3854 without the ''.
I have a program that uses the post method, but it needs some keys and values...that value changes all the time so i need it to search it from an .txt(key.txt) file and them send it to the prog so it can do the Post..etc..
the part of the prog is:
var rawfile = key.txt (THIS WILL BE THE HTML SOURCE TXT FILE)
get url http://www.berny.com/Scripts/ENTERMSG.asp?group=&kkey=&pass_id=213453
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 = http://www.berny.com/Scripts/ENTERMSG.asp?group=&kkey=&pass_id=213453
post url http://www.berny.com/Scripts/ENTERMSG.asp
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...
Ex:
<body>
.......
<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>
it would read the txt with the html source code and show the third line value.. for ex: print EF3854 without the ''.
I have a program that uses the post method, but it needs some keys and values...that value changes all the time so i need it to search it from an .txt(key.txt) file and them send it to the prog so it can do the Post..etc..
the part of the prog is:
var rawfile = key.txt (THIS WILL BE THE HTML SOURCE TXT FILE)
get url http://www.berny.com/Scripts/ENTERMSG.asp?group=&kkey=&pass_id=213453
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 = http://www.berny.com/Scripts/ENTERMSG.asp?group=&kkey=&pass_id=213453
post url http://www.berny.com/Scripts/ENTERMSG.asp
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...
ASKER
One of the scripts in perl that the prog uses is bellow:
__________________________ __________ ___
# 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=&kk ey=&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=&kke y=&ID=6352 070"> (6352070) </a><br>
<a href="/Scripts/CLASSD.asp? group=&kke y=&ID=6352 075"> 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...
__________________________
# 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\
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.
<a href="/Scripts/CLASSD.asp?
<a href="/Scripts/CLASSD.asp?
<center><img src="/wsdocs/cyber/PR_BAR.
<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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Personally I always "roll it myself" so I use soemthing like:
$x=<STDIN>;
@vals=split("&",$x);
but you can use whatever method you like. Most people seem to like the CGI.pm module.