bcdeery,
When I have had to reverse engineer JavaScript code I use the 'view source' option of my browser (or simply retrieve the file if its an include file) and port the code over to Perl. However, from having looked at this page, all the submitTTime() function (which is called when you click 'Calculate') does is sets a hidden form value and then submit the form. If you use WWW::Mechanize you can set the form value and submit the form.
The JavaScript line:
document.frmSvcCalc.hdnAction.value = "Calculate";
Sets the value of hdnAction to "Calculate". To use WWW::Mechanize to do this try:
$mech->field( "hdnAction", "Calculate" );
before submitting the form. Sadly I can not test this right now (no Perl on desktop machine, no internet access on our development boxes), let me know if you have any problems.
Hope this helps.
Martin | [reply] [d/l] [select] |
"DHL Ground Service</a> <br> (Letter – 150 Pounds)</div></td>
+
<td><div class="pL5">Monday, Jan 9, 2006 &n
+bsp;By end of day<img src="http://www.dhl-usa.com/images/blank.gif" w
+idth="1" height="1"></div></td>
<td><div class="pL5">1"
but it will find "help you create, print, and pay your shipping" which is only found on the same page.
I need to extract the last "1" from the string. Any ideas how? Do I have to do a search for "DHL Ground Service" and then somehow search only what is in the response after that for the string connected to the number one that I'm looking for?
Sorry this post is funny, I don't know how to disable the HTML tags on my post. Thanks again to anybody who can help! | [reply] [d/l] |
Hi bcdeery,
Looks like you forgot to login before posting your reply.
"Yes this worked. When it prints URI it gives the original url, but when I print the code to a file, I can verify that it has indeed gone to the correct page. Any idea why that is?"
It is because the content of the page is dynamically generated. The URL is the same, but the content of the page is different because you submitted the form with the values needed to process your input (inserting values into the form fields and setting "hdnAction" = "Calculate"). As for dealing with the output, I prefer to use HTML::TokeParser or HTML::TokeParser::Simple to parse out the data I want from the HTML tags. I prefer this method to using a regex as you can't always depend on good quality data, and these modules are tried and tested :) Read the module documentation get the drift of how to use them, I wont post an example as there are good examples to work with in the docs.
Hope this helps.
Martin
| [reply] |
| [reply] |
You might want to take a look at IE::Mechanize. | [reply] |