sdspieg Posted January 14, 2012 Report Share Posted January 14, 2012 I am trying to create a macro to automate some actions I would like to perform on a website. But the actions themselves appear to be in javascript. Is there any way to run those from within MEX? Or at least to find a way for MEX to 'find' the appropriate javascript on that page (e.g. by searching on the page source?) and then click on it? Thanks! -Stephan Quote Link to comment Share on other sites More sharing options...
paul Posted January 15, 2012 Report Share Posted January 15, 2012 What browser are you using? Quote Link to comment Share on other sites More sharing options...
sdspieg Posted January 15, 2012 Author Report Share Posted January 15, 2012 Normally Chrome, but I also have MSIE and Firefox installed.... Quote Link to comment Share on other sites More sharing options...
paul Posted January 15, 2012 Report Share Posted January 15, 2012 Does this help? Running JavaScript within a browser Quote Link to comment Share on other sites More sharing options...
Cory Posted January 15, 2012 Report Share Posted January 15, 2012 I have examples here in the forum of how you could download the raw HTML text using a simple VBScript. But I doubt you could run the Java-Script outside the browser session. I've been writing scrapers lately for clients and found that MEP just became too difficult to manage and instead I have been writing VB.NET application's to do it. I manage to log in, navigate, and execute all kinds of actions all via HTTPWebRequests. This was necessary because the requests all require session cookies that would be difficult or impossible to do any other way. But I'm curious. Why do you want to run the JS outside otheeh web browser? IE whcan't't you simply click on the button or what have you? Quote Link to comment Share on other sites More sharing options...
sdspieg Posted January 15, 2012 Author Report Share Posted January 15, 2012 I have examples here in the forum of how you could download the raw HTML text using a simple VBScript. But I doubt you could run the Java-Script outside the browser session. I've been writing scrapers lately for clients and found that MEP just became too difficult to manage and instead I have been writing VB.NET application's to do it. I manage to log in, navigate, and execute all kinds of actions all via HTTPWebRequests. This was necessary because the requests all require session cookies that would be difficult or impossible to do any other way. But I'm curious. Why do you want to run the JS outside otheeh web browser? IE whcan't't you simply click on the button or what have you? Thanks. Well the site has multiple pages, and the only way to go to the next page is to click on the 'next page' button, which is not always in the exact same place (it shows previous - 1 - 2 - 3 - ... - next; and so when you get to 10 - 11 - 12 etc the next is more to the right)... -Stephan Quote Link to comment Share on other sites More sharing options...
sdspieg Posted January 15, 2012 Author Report Share Posted January 15, 2012 Does this help? Running JavaScript within a browser Thanks Paul, but no it doesn't. I've tried this trick in Chrome (where it just assumes I want to do a google search) AND in Firefox (which does nothing when I paste the code in the URL and then click on enter). FYI - the code I added is sthg like javascript:addAll();void(0); Cheers, -Stephan Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 16, 2012 Report Share Posted January 16, 2012 Thanks Paul, but no it doesn't. I've tried this trick in Chrome (where it just assumes I want to do a google search) AND in Firefox (which does nothing when I paste the code in the URL and then click on enter). FYI - the code I added is sthg like javascript:addAll();void(0); Seems to work here in FF 9.0.1. Initially I got this warning: After changing that setting in about:config I tried again but nothing appeared to happen. But when I removed that 'void' piece, I got a result that I assume was the expected one: -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
sdspieg Posted January 17, 2012 Author Report Share Posted January 17, 2012 Seems to work here in FF 9.0.1. Initially I got this warning: After changing that setting in about:config I tried again but nothing appeared to happen. But when I removed that 'void' piece, I got a result that I assume was the expected one: -- Terry, East Grinstead, UK Terry, thanks. When I typed about:config, I saw no such string. So I added it manually, type boolean, value true (it says 'user set' - is that ok?). But it still doesn't change anything. Am I missing sthg? I am using the latest version of Firefox... BTW - I CAN now replicate YOUR example, but when I enter the javascript code that I see in the source page of the webpage on which I'm trying to automate some actions, I get no response whatsoever.. Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 18, 2012 Report Share Posted January 18, 2012 Sorry, but as you saw I'm not into JavaScript. And I'd expect anyone here that is would need to see full details before suggesting an explanation. As for the about:config missing entry, I'd suggest you post a query in the Firefox Support forum -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Cory Posted January 23, 2012 Report Share Posted January 23, 2012 Thanks. Well the site has multiple pages, and the only way to go to the next page is to click on the 'next page' button, which is not always in the exact same place (it shows previous - 1 - 2 - 3 - ... - next; and so when you get to 10 - 11 - 12 etc the next is more to the right)... -Stephan FYI this can actually be done but it gets into the realm of real programming. I have scrapers that start at one page, collect a cookie, and navigate thru subsequent pages all using the .NET WebRequest class. It'a all invisible and super fast and super reliable. You may have contacted me offline and in my response I explained in detail. Just wanted to mention it in case you didn't receive my emails. Too many over zealous spam filters these days. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.