in reply to WIN32::IE::Mechanize - can't follow link - JavaScript involved
You have not posted the js code linked to the page, so there is very little we can do
In the original HTML page there should be one (or more) <script> tag that contains or javascript code or a url from which the code is downloadable (follow the link with your browser and then "view page source")
Updated: WIN32::IE::Mechanize has some limits regarding HTML pages containing frames and JS popups. You should check then entire HTML page and the associated JS code
Are you sure that this couldn't be better done with CGI?
Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: WIN32::IE::Mechanize - can't follow link - JavaScript involved
by Ninth Prince (Acolyte) on May 22, 2008 at 17:08 UTC | |
Oops, sorry about that. I don't know enough about JavaScript to even know that I should have given you all or the HTML. Anyway, here it is.
What is it that I'm looking for? Thanks. | [reply] [d/l] |
by psini (Deacon) on May 22, 2008 at 17:33 UTC | |
Near the beginning of the file, there are six lines:
that tell the browser to load the corresponding scripts (eg /IAPD/Includes/Validation/Search/iapd_OrgSearch.js and the other two). If you follow the links (they are relative to the URL from which you got the HTML page) you can get the scripts. Then, in one the three scripts, you will find the javascript code which lays behind the page. Reading better the HTML I see a strange thing: <img SRC="/IAPD/Images/go_off.gif" alt="Go" name="go2" onMouseover="JImgAct('go2')" onMouseout="JImgInact('go2')" BORDER="0" align="top"> is the definition of the object that you call "Button GO2", but it is not a button, it is a image and I see handlers only for onMouseover and onMouseut (called when the mous pass over the image and when it exits from the image). For this to act as a button, it should have a handler for onClick, too. Are you sure that this is the right object? Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man. | [reply] [d/l] [select] |
by Ninth Prince (Acolyte) on May 22, 2008 at 18:10 UTC | |
No, I'm not sure, but it seems like the correct object to me. By way of background, this is a form that appears on the Securities and Exchange Commission's web site that investors can use to get information about investment advisors. The URL is http://www.adviserinfo.sec.gov/IAPD/Content/Search/iapd_OrgSearch.aspx. When I open this page up in a regular browser I fill in the field next to the label "CrdNumber" with a known value for an existing investment advisor (the value I use is 144549). To submit the form, I click on what looks like a "button" that is next to the field that I filled in. This process gets me to the page (information) that I really want. This is the process that I would like to automate over a large number of investment advisors Although I have never worked with JS, I have worked a little with Java, so it seemed odd to me that there was no "onClick()" method in the underlying source code. There was an earlier thread that I read that had a similar issue and the advice was that the object is not, in fact, a button. That thread suggested using ie->follow_link() which is why I tried adding it to my code. One other thing, although there are four (4) forms on the page, once I have filled in the CrdNumber field, if I click on ANY of the "submit" buttons (they all have different names) my submission works fine. The reasons for this are probably obvious to someone with more coding experience than myself, but it is a mystery to me. I'm going to try to follow those (relative) URLs from the JS lines. I will get back on that. Thanks for you advice. | [reply] [d/l] |
by psini (Deacon) on May 22, 2008 at 18:29 UTC | |
by Ninth Prince (Acolyte) on May 22, 2008 at 19:39 UTC | |
| |
by Ninth Prince (Acolyte) on May 22, 2008 at 18:33 UTC | |
Okay, I followed the JavaScipt script that looked like it would be the right one and I think it is. Here is the content. You can see that it includes the JSubmitForm() function call that appears in the "go2" button (that isn't a button!?).
With the JS code in hand, how do I attack my original problem of getting the form to submit? Thanks! | [reply] [d/l] |
by psini (Deacon) on May 22, 2008 at 19:01 UTC | |
by Ninth Prince (Acolyte) on May 22, 2008 at 20:32 UTC | |