Jump to content
Macro Express Forums

Running javascript from within Macro Express?


Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

 

FF-Javascript-1.jpg

 

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:

 

FF-Javascript-2.jpg

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Seems to work here in FF 9.0.1.

 

Initially I got this warning:

 

FF-Javascript-1.jpg

 

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:

 

FF-Javascript-2.jpg

 

--

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...