Inject JS, save resulting page, continue to next page?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
antiqueferret
Posts: 2
Joined: Wed Sep 21, 2022 5:35 pm

Inject JS, save resulting page, continue to next page?

Post by antiqueferret » Wed Sep 21, 2022 5:44 pm

FCI: (Added by Mod from some "later" Post)
I'm using a mac running os 12.5.1 (Monterey) and Chrome browser 105.0.5195.125 (Official Build) (x86_64). I am using iMacros version build 1011. Everything is running in English. I haven't altered any settings, browser and imacros are being used as they arrived, fresh out the box.

=> FCI:

Code: Select all

iMacros for CR v10.1.1 'Free', CR105, macOS v12.5.1 (Monterey). (All ENG)
>>>

I am new to imacros, so my apologies if my ask is difficult or incorrect in some way.

I want to create a macro that opens web dev tools, selects the console, and injects a bit of Javascript. This Javascript in turn generates a new page with a table of data gleaned from the webpage. I would like that page to save (preferably in a numerated order), and then close. Then, within the webpage, I want it to continue to the next page in the pagination, and repeat the process.

I have tried using imacros to simply save a given page to desktop, but as it is a trial version, I don't have that ability. If I were able to do my abovementioned series of tasks, then I would definitely purchase, but until I am sure it's doable, I am reluctant to pay out.

Thank you for your assistance.
Last edited by chivracq on Thu Sep 22, 2022 9:27 pm, edited 2 times in total.
Reason: FCI added to OP from some later Post in the Thread...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Inject JS, save resulting page, continue to next page?

Post by chivracq » Wed Sep 21, 2022 9:28 pm

antiqueferret wrote:
Wed Sep 21, 2022 5:44 pm
I am new to imacros, so my apologies if my ask is difficult or incorrect in some way.

I want to create a macro that opens web dev tools, selects the console, and injects a bit of Javascript. This Javascript in turn generates a new page with a table of data gleaned from the webpage. I would like that page to save (preferably in a numerated order), and then close. Then, within the webpage, I want it to continue to the next page in the pagination, and repeat the process.

I have tried using imacros to simply save a given page to desktop, but as it is a trial version, I don't have that ability. If I were able to do my abovementioned series of tasks, then I would definitely purchase, but until I am sure it's doable, I am reluctant to pay out.

Thank you for your assistance.

Thread moved to the 'General' Sub-Forum, nothing specific to the 'iMacros for FF' Sub=Forum ("at the moment") as you don't even mention your FCI (explained in the Forum Rules, ... that you didn't read...! :( ), the "Inject JS" Part in your Thread Title could be done using a '.js' Script indeed, but you mention "somewhere" in your OP "trial version", and Septb 2022, there are no Versions with a Trial Version that ("currently") support '.js' Scripts, oops...! :?
... And only iMacros for FF supports/supported 'js' Scripts (until v9.x), so Threads about a '.js' Script do belong to the 'iMacros for FF' Sub-Forum indeed... (But "Inject JS" can also be done in pure '.iim' using the `URL GOTO=javascript:` Syntax, which is then supported by all Versions...)
(But I'll be able to move the Thread again, if needed, to a "better" Sub-Forum, once you'll have provided more Info... :wink: )

=> CIM...! :mrgreen: (Read the Forum Rules, ... and my Sig... :idea: )

Difficult to answer your OP/Qt without knowing your FCI... :(
=> "I have tried using imacros to simply save a given page to desktop, but as it is a trial version, I don't have that ability."
Beh..., no!, not true, all 'Trial' Versions support the `SAVEAS` Command, but all 'PE'/'Trial' Versions are fully Functional only on OS=Win[7-11], not on macOS or Linux, so pfff..., mention your FCI and we "can start from that", otherwise my Reply/Post will be a complete succession of IF/IF/IF... :idea:

+ Hum..., your Post/OP is pretty vague also, no Script posted and no Info about "what exactly" you want to implement, I won't be able to "think with you" (I already suspect some "X/Y Problem" actually, to be honest), then I only provide some "generic" Advice... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
antiqueferret
Posts: 2
Joined: Wed Sep 21, 2022 5:35 pm

Re: Inject JS, save resulting page, continue to next page?

Post by antiqueferret » Thu Sep 22, 2022 3:45 pm

I'm using a mac running os 12.5.1 (Monterey) and Chrome browser 105.0.5195.125 (Official Build) (x86_64). I am using iMacros version build 1011. Everything is running in English. I haven't altered any settings, browser and imacros are being used as they arrived, fresh out the box.

The javascript I want to use is this:

Code: Select all

var w = window.open("");
w.document.write("<table><thead><th>Name<th>Links<tbody>");
for(var x of document.querySelectorAll("a"))
w.document.write( "<tr><td>"+ x.textContent + "<td>"+x.href);
Injecting it manually works just fine, it's just very tedious because the site in question has millions of pages.

Did I miss anything? I'm sorry, I have zero idea what I'm doing.
Last edited by chivracq on Thu Sep 22, 2022 9:36 pm, edited 1 time in total.
Reason: Several Layers of Quoting removed, not needed... (For Readability...)
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Inject JS, save resulting page, continue to next page?

Post by techimac » Fri Sep 23, 2022 2:13 am

antiqueferret wrote:
Thu Sep 22, 2022 3:45 pm
I'm using a mac running os 12.5.1 (Monterey) and Chrome browser 105.0.5195.125 (Official Build) (x86_64). I am using iMacros version build 1011. Everything is running in English. I haven't altered any settings, browser and imacros are being used as they arrived, fresh out the box.

The javascript I want to use is this:

Code: Select all

var w = window.open("");
w.document.write("<table><thead><th>Name<th>Links<tbody>");
for(var x of document.querySelectorAll("a"))
w.document.write( "<tr><td>"+ x.textContent + "<td>"+x.href);
Injecting it manually works just fine, it's just very tedious because the site in question has millions of pages.

Did I miss anything? I'm sorry, I have zero idea what I'm doing.
If you have Windows then get Enterprise trial and use VBS/VBA.

if website supports older browser then use Firefox 56, iMacros 8.9.7 on Mac.

How many pages are there?
It is available for public?
I can scrape it for you.
Available for custom iim, javascript iMacros scripts
Post Reply