extract script using REGEXP=Source failed

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
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
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

extract script using REGEXP=Source failed

Post by rajtak » Fri Aug 17, 2018 11:10 am

How do I extract the enter line after 'colorimages' below? I have tried several things but failed to get the desired output. Any help regarding this would really be appreciated. Thank you in advance.

Code: Select all

P.when('A').register("ImageBlockATF", function(A){
    var data = {
                'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SL1500_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY445_.jpg":[445,93],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY500_.jpg":[500,104],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY550_.jpg":[550,115],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY606_.jpg":[606,126],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY679_.jpg":[679,141]},"variant":"MAIN","lowRes":null},{"hiRes":null,"thumb":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX342_.jpg":[327,342],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX385_.jpg":[368,385],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX425_.jpg":[406,425],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX466_.jpg":[445,466],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg":[478,500]},"variant":"PT02","lowRes":null}]},
                'colorToAsin': {'initial': {}},
                'holderRatio': 0.84,
                'holderMaxHeight': 700,
                'heroImage': {'initial': []},
                'heroVideo': {'initial': []},
                'spin360ColorData': {'initial': {}},
                'spin360ColorEnabled': {'initial': 0},
                'spin360ConfigEnabled': true,
                'playVideoInImmersiveView':'false',
                'tabbedImmersiveViewTreatment':'T2',
                'totalVideoCount':'0',
                'videoIngressATFSlateThumbURL':'',
                'mediaTypeCount':'0',
                'atfEnhancedHoverOverlay' : false,
                'weblabs' : {},
                'aibExp3Layout' : 0,
                'aibRuleName' : ''
                };
    A.trigger('P.AboveTheFold'); // trigger ATF event.
    return data;
});
</script>
Here is what i tried

Code: Select all

SEARCH SOURCE=REGEXP:"\'colorImages\'.*" EXTRACT=$1
SET !VAR1 {{!EXTRACT}}
PROMPT {{!EXTRACT}}
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Fri Aug 17, 2018 12:01 pm

rajtak wrote:How do I extract the enter line after 'colorimages' below? I have tried several things but failed to get the desired output. Any help regarding this would really be appreciated. Thank you in advance.

Code: Select all

P.when('A').register("ImageBlockATF", function(A){
    var data = {
                'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SL1500_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY445_.jpg":[445,93],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY500_.jpg":[500,104],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY550_.jpg":[550,115],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY606_.jpg":[606,126],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY679_.jpg":[679,141]},"variant":"MAIN","lowRes":null},{"hiRes":null,"thumb":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX342_.jpg":[327,342],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX385_.jpg":[368,385],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX425_.jpg":[406,425],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX466_.jpg":[445,466],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg":[478,500]},"variant":"PT02","lowRes":null}]},
                'colorToAsin': {'initial': {}},
                'holderRatio': 0.84,
                'holderMaxHeight': 700,
                'heroImage': {'initial': []},
                'heroVideo': {'initial': []},
                'spin360ColorData': {'initial': {}},
                'spin360ColorEnabled': {'initial': 0},
                'spin360ConfigEnabled': true,
                'playVideoInImmersiveView':'false',
                'tabbedImmersiveViewTreatment':'T2',
                'totalVideoCount':'0',
                'videoIngressATFSlateThumbURL':'',
                'mediaTypeCount':'0',
                'atfEnhancedHoverOverlay' : false,
                'weblabs' : {},
                'aibExp3Layout' : 0,
                'aibRuleName' : ''
                };
    A.trigger('P.AboveTheFold'); // trigger ATF event.
    return data;
});
</script>
Here is what i tried

Code: Select all

SEARCH SOURCE=REGEXP:"\'colorImages\'.*" EXTRACT=$1
SET !VAR1 {{!EXTRACT}}
PROMPT {{!EXTRACT}}
CIM...! :mrgreen:
=> ... Mention your FCI for me to have a look, read my Sig, I've already told you I don't answer Threads if FCI is not mentioned......
Hum..., and wondering what is specific to the 'iMacros for FF' Sub-Forum...? Or does your Script work in some previous/other Version of iMacros for FF (if you are on FF...), or in some other Browser...? :? (But no need to open a Duplicate if you only chose a "random" Sub-Forum...)

I don't "do" 'REGEXP' that I don't like and find too "complicated", so I will use a different Technique... :wink:

But hum, it would be easier if you could mention the URL, and I don't really understand what you mean exactly with "... the enter line after 'colorimages' below?"...? => Mention what Output exactly you expect...?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Sat Aug 18, 2018 2:14 am

Hello Chivracq,
Apologies if I have chosen a wrong forum topic. I am using iMacros's inbuilt browser and OS is Windows 7.

Basically, I need to pull hi-resolution image URL from Amazon's product detail page. You can find this code in any product detail page of Amazon. Here is an example URL https://www.amazon.com/dp/B01J94TJKO

The Output that I am looking for is below

Code: Select all

'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SL1500_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY445_.jpg":[445,93],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY500_.jpg":[500,104],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY550_.jpg":[550,115],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY606_.jpg":[606,126],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY679_.jpg":[679,141]},"variant":"MAIN","lowRes":null},{"hiRes":null,"thumb":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX342_.jpg":[327,342],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX385_.jpg":[368,385],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX425_.jpg":[406,425],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX466_.jpg":[445,466],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg":[478,500]},"variant":"PT02","lowRes":null}]},
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Sat Aug 18, 2018 3:22 am

rajtak wrote:Hello Chivracq,
Apologies if I have chosen a wrong forum topic. I am using iMacros's inbuilt browser and OS is Windows 7.

Basically, I need to pull hi-resolution image URL from Amazon's product detail page. You can find this code in any product detail page of Amazon. Here is an example URL https://www.amazon.com/dp/B01J94TJKO

The Output that I am looking for is below

Code: Select all

'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SL1500_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/415%2B0wXFUtL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY445_.jpg":[445,93],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY500_.jpg":[500,104],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY550_.jpg":[550,115],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY606_.jpg":[606,126],"https://images-na.ssl-images-amazon.com/images/I/711HLGabj7L._SY679_.jpg":[679,141]},"variant":"MAIN","lowRes":null},{"hiRes":null,"thumb":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX38_SY50_CR,0,0,38,50_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX342_.jpg":[327,342],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX385_.jpg":[368,385],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX425_.jpg":[406,425],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L._SX466_.jpg":[445,466],"https://images-na.ssl-images-amazon.com/images/I/61hQcp2GK1L.jpg":[478,500]},"variant":"PT02","lowRes":null}]},

Code: Select all

iMacros's inbuilt browser and OS is Windows 7
Ah, OK, so hum, not even using iMacros for FF, and the iMB Version is still missing... But, OK, never mind, I guess that will be too "complicated"...

But, URL mentioned, perfect, then I can test the "Technique" I had in mind, which simply consists of using 'EVAL()' + 2x 'split()':

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://www.amazon.com/dp/B01J94TJKO

TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT
SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
PROMPT Color_Images:<BR><BR>_{{Color_Images}}_
... which seems to work directly and returns the following Output in the 'PROMPT' for this specific Page:

Code: Select all

Color_Images:

_'colorImages': { 'initial': [{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/51iZ%2BcDZVTL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/51iZ%2BcDZVTL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/71iAnQiElJL._SX679_.jpg":[679,679]},"variant":"LEFT","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/51cAPzeEGPL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/51cAPzeEGPL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/61ZAWVoW9BL._SX679_.jpg":[679,679]},"variant":"MAIN","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/51Gw4%2Bsqn%2BL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/51Gw4%2Bsqn%2BL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/61RWVyZ6lFL._SX679_.jpg":[679,679]},"variant":"PT01","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/61IkVYSGl9L._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/61IkVYSGl9L.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/81R4DcTgofL._SX679_.jpg":[679,679]},"variant":"PT02","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/51XnxY3%2B8ZL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/51XnxY3%2B8ZL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/61piK1PyAaL._SX679_.jpg":[679,679]},"variant":"PT03","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/51jh2HmyInL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/51jh2HmyInL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/61yS88BWtbL._SX679_.jpg":[679,679]},"variant":"PT04","lowRes":null},{"hiRes":"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SL1000_.jpg","thumb":"https://images-na.ssl-images-amazon.com/images/I/511VWPUroIL._SS40_.jpg","large":"https://images-na.ssl-images-amazon.com/images/I/511VWPUroIL.jpg","main":{"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SY355_.jpg":[355,355],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SY450_.jpg":[450,450],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SX425_.jpg":[425,425],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SX466_.jpg":[466,466],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SX522_.jpg":[522,522],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SX569_.jpg":[569,569],"https://images-na.ssl-images-amazon.com/images/I/61B9InuVxPL._SX679_.jpg":[679,679]},"variant":"PT05","lowRes":null}]},_
(Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), Win10_x64.)

The 2x '_' surrounding the Output are only meant as Delimiters for the Output in the 'PROMPT'...
Last edited by chivracq on Wed Aug 22, 2018 1:23 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Tue Aug 21, 2018 11:01 pm

Hum, not really "impressed" by the Follow-up on this Thread, 4 or 5 days later, oops...! :shock:

And I always thought that Follow-up (with Customers/Stake Holders/Business/Developers/Other Project Members/etc...) belonged to the "basic" Skill-Set of a "Project Manager" (from your iMacros Profile), oops, silly me...! :?
Kind of wondering what kind of Projects you are trusted to manage, then...? :?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Fri Sep 14, 2018 9:06 am

Please accept my apology for the delay in replying. I was out of town for a while and had a little internet connection throughout. You are a genius a brother. Your code helped me a lot and saved a lot of time.
Thanks,
Raj
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Fri Sep 14, 2018 9:14 am

Is there a way extracting the text in PROMPT that you shown without extracting the TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT in a csv file?
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Fri Sep 14, 2018 4:36 pm

rajtak wrote:Please accept my apology for the delay in replying. I was out of town for a while and had a little internet connection throughout. You are a genius a brother. Your code helped me a lot and saved a lot of time.
rajtak wrote:Is there a way extracting the text in PROMPT that you shown without extracting the TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT in a csv file?
Oh...!, you are still alive...!, 3 or 4 weeks later...! What a good news...! :D
Hum..., yeah, bad "timing" indeed that you went on holiday for 3 weeks exactly in the 1 hour that I replied and posted my Solution, OK, never mind... :wink:
Was an interesting Case anyway...

Hum..., I don't really understand your next Qt... :?
"extracting the text in PROMPT" doesn't make sense... You don't need to "extract" anything from a 'PROMPT', as the Script is already in Full Control over the Content of the 'PROMPT'... The 'Color_Images' Var I used contains the Data that you want...

And "without extracting the [...] in a csv file?" even makes less sense, you don't extract "in", you extract "from" (a Web-Page), and the Extract Process has nothing to do with a '.csv' File...
But if maybe you want to save (only) the "cleaned" Data from the 'EVAL()' to a '.csv' File, then simply use the "standard" Functionality of the 'SAVEAS' Command:

Code: Select all

SET !EXTRACT {{Color_Images}}
SAVEAS TYPE=EXTRACT FOLDER=xxx FILE=yyy.csv
But hum, if you've been using iMacros since 2009 already, I guess that's not what you mean, as this is very "Basic" Functionality/Use of iMacros... Give more "Details", I don't understand your Qt... :oops:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Sat Sep 15, 2018 2:31 am

Hello,
Thank you for your reply and sorry if my question didn't make sense.

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://www.amazon.com/dp/B01J94TJKO

TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT
SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
PROMPT Color_Images:<BR><BR>_{{Color_Images}}_
The suggested code above also saves the full text from here to a CSV file

Code: Select all

TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT 
and then the cleaned info in a next column

Code: Select all

SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
PROMPT Color_Images:<BR><BR>_{{Color_Images}}_
I updated the above one like this to make it go into the CSV

Code: Select all

SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
ADD !EXTRACT {{Color_Images}}
My question is, I only want the cleaned info not the full text extracted from the web page. Hope I am making sense :)

Thank you for your help.
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Sat Sep 15, 2018 2:39 am

rajtak wrote:Hello,
Thank you for your reply and sorry if my question didn't make sense.

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://www.amazon.com/dp/B01J94TJKO

TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT
SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
PROMPT Color_Images:<BR><BR>_{{Color_Images}}_
The suggested code above also saves the full text from here to a CSV file

Code: Select all

TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT 
and then the cleaned info in a next column

Code: Select all

SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
PROMPT Color_Images:<BR><BR>_{{Color_Images}}_
I updated the above one like this to make it go into the CSV

Code: Select all

SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
ADD !EXTRACT {{Color_Images}}
My question is, I only want the cleaned info not the full text extracted from the web page. Hope I am making sense :)

Thank you for your help.
Beh..., yep of course, if you use 'ADD !EXTRACT' you get both, but if you use 'SET !EXTRACT' (like I did), then you only get the clean Data...!
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Sat Sep 15, 2018 2:49 am

Awesome, It worked. Thanks a lot!!!
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Sat Sep 15, 2018 2:57 am

rajtak wrote:Awesome, It worked. Thanks a lot!!!
Ah OK..., but yep, "logical" Difference between 'ADD' and 'SET', ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Tue Sep 18, 2018 5:55 am

Hello chivracq,
Please let me know why the below code does not save both Description and Images into a CSV file? What should I do to get both information captured into a CSV file?

Code: Select all

URL GOTO=https://www.amazon.com.mx/dp/B07CRY1HXH?th=1&psc=1

'Description
TAG POS=1 TYPE=SCRIPT ATTR=TXT:*productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A* EXTRACT=TXT
SET prod_desc EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A'); y=x[1].split('emptyClear%22%3E'); z=\"'productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A\"+y[0]+'emptyClear%22%3E,'; z;")
'PROMPT Desc:<BR><BR>_{{prod_desc}}_
SET !EXTRACT {{prod_desc}}

'Images
TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT
SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
SET !EXTRACT {{Color_Images}}

SAVEAS TYPE=EXTRACT FOLDER=* FILE=TEST3_DwL.csv
Thank you for your help in advance.
Thanks,
Raj
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: extract script using REGEXP=Source failed

Post by chivracq » Tue Sep 18, 2018 12:39 pm

rajtak wrote:Hello chivracq,
Please let me know why the below code does not save both Description and Images into a CSV file? What should I do to get both information captured into a CSV file?

Code: Select all

URL GOTO=https://www.amazon.com.mx/dp/B07CRY1HXH?th=1&psc=1

'Description
TAG POS=1 TYPE=SCRIPT ATTR=TXT:*productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A* EXTRACT=TXT
SET prod_desc EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A'); y=x[1].split('emptyClear%22%3E'); z=\"'productDescriptionWrapper%22%20dir%3D%22auto%22%20%3E%0A\"+y[0]+'emptyClear%22%3E,'; z;")
'PROMPT Desc:<BR><BR>_{{prod_desc}}_
SET !EXTRACT {{prod_desc}}

'Images
TAG POS=1 TYPE=SCRIPT ATTR=TXT:*colorImages* EXTRACT=TXT
SET Color_Images EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('colorImages'); y=x[1].split('null}]}'); z=\"'colorImages\"+y[0]+'null}]},'; z;")
SET !EXTRACT {{Color_Images}}

SAVEAS TYPE=EXTRACT FOLDER=* FILE=TEST3_DwL.csv
Thank you for your help in advance.
Yeah, normal, because you use "SET !EXTRACT" just before the 'SAVEAS', meaning you just replaced the original Content in the '!EXTRACT' Var (coming from the 'EXTRACT' Mechanism before in your Script) with some new Content, and the 'SAVEAS' will "only" save what you've just put in the '!EXTRACT' Var...!

If you want to save both the original Content of '!EXTRACT' (coming from the 'EXTRACT' Statement(s) before) + the "clean Data" from the 'EVAL()', you need to use "ADD !EXTRACT" (and not "SET !EXTRACT")...!

(And if you want those 2 in the different order, you need to save the original '!EXTRACT' into some Temp Var, then to do the 'SET !EXTRACT' with the Content of the 'EVAL()' and to re-add the Temp Var to the '!EXTRACT' Var with "ADD !EXTRACT"...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

Re: extract script using REGEXP=Source failed

Post by rajtak » Wed Sep 19, 2018 3:50 am

I want to save only the clean data in both instances and do not need the Original content. If I use ADD !EXTRACT it saves both original and clean data. Please let me know how to set temp var?
Thanks,
Raj
Post Reply