Extract & Verify

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
Post Reply
vin
Posts: 4
Joined: Wed Apr 12, 2017 3:25 pm

Extract & Verify

Post by vin » Wed Apr 12, 2017 3:28 pm

Is there a way to extract a particular data from web page & compare it with a predefined values to return True or False
[ iMacros 11.5.499.3066 + IE 11 + Windows 10 ]
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract & Verify

Post by chivracq » Wed Apr 12, 2017 3:51 pm

vin wrote:Is there a way to extract a particular data from web page & compare it with a predefined values to return True or False
Hum..., low Quality Thread... :idea:
=CIM...! :mrgreen: (read my Sig...)

To answer your Qt, => yep, use 'EXTRACT' and 'EVAL()'...
- (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...
vin
Posts: 4
Joined: Wed Apr 12, 2017 3:25 pm

Re: Extract & Verify

Post by vin » Wed Apr 12, 2017 4:09 pm

CIM: iMacros + IE11+ Windows 10

:lol: Thanks!
[ iMacros 11.5.499.3066 + IE 11 + Windows 10 ]
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract & Verify

Post by chivracq » Wed Apr 12, 2017 4:23 pm

vin wrote:CIM: iMacros + IE11+ Windows 10

:lol: Thanks!
Yeah, iMacros Version Version still missing..., v11.5 I reckon... :roll:

And you are expected to share your Solution once you've got your Script working...
- (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...
vin
Posts: 4
Joined: Wed Apr 12, 2017 3:25 pm

Re: Extract & Verify

Post by vin » Wed Apr 12, 2017 5:27 pm

Great!

Manipulated extracted string using EVAL
SET !EXTRACT EVAL("var s=\"{{!EXTRACT}}\"; if (s.indexOf('Not Paid') > 0) {s += ', -> OK'} else {s += ', -> Failed'} ")
[ iMacros 11.5.499.3066 + IE 11 + Windows 10 ]
vin
Posts: 4
Joined: Wed Apr 12, 2017 3:25 pm

Re: Extract & Verify

Post by vin » Wed Apr 12, 2017 5:29 pm

Also I am doing SAVEAS to save multiple extractions in CSV, But they get added in a single row of CSV.

Is there way to add them in single column without writing additional string manipulation code?
[ iMacros 11.5.499.3066 + IE 11 + Windows 10 ]
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract & Verify

Post by chivracq » Thu Apr 13, 2017 2:14 am

vin wrote:Great!

Manipulated extracted string using EVAL
SET !EXTRACT EVAL("var s=\"{{!EXTRACT}}\"; if (s.indexOf('Not Paid') > 0) {s += ', -> OK'} else {s += ', -> Failed'} ")

Code: Select all

[ iMacros 11.5.499.3066 + IE 11 + Windows 10 ]
Finally OK for FCI, eh-eh...!
But hum, FCI in your Sig denotes from a good Intention but still doesn't "free" you from hard-coding it in your OP when you open a Thread...
Explanation is that you only have one Dynamic Sig for the whole Forum, so your Sig changes for all your (previous) Threads as soon as you change it, and it will look very suspicious in 2027 that you were already using [iMacros v138 + IE349 on WinSuperGallaxy_v9999] back in 2017...!

OK, Thanks for sharing your Sol...!
Ah-ah..., good-good, I always forget about this Use of 'indexOf()>0', quite clever, I usually do the same with 'split()' (+'length')...

Mini-Feedback:
I consider "bad Practice" to do direct Manipulation on 'EXTRACT' for Debug Purpose, because if your 'EVAL()' Statement doesn't work directly, you cannot use 'PROMPT' to debug your Script, or you need to use several 'PROMPT's before and after the 'EVAL()' and save them manually in some Temp-TXT File, which is a bit of a hassle I would think...
=> I think it's better to do your Data-Manipulation on some Temp-Var and to reconstruct the Content of '!EXTRACT' at the last moment just before doing the 'SAVEAS'... Your 'indexOf()' Method for example could be completely "screwed" if you added some extra Extract before the last one..., hum, "my" 'split()' as well in your case, but I always "work" with 'EVAL()' on a "clean" Single Extract..., which allows me when adding some extra Extracts to only think about what I want to add at that moment and not have to worry about trying to decode what I might have wanted to do 1.5 years ago, which works of course, but shit, why the last 'EVAL()' produces some unexpected Result...!?
(OK, my Personal Opinion, based on my own Experience, for myself of course, but on debugging many-many Scripts from the Forum as well that were not written by me...)
vin wrote:Also I am doing SAVEAS to save multiple extractions in CSV, But they get added in a single row of CSV.

Is there way to add them in single column without writing additional string manipulation code?
One 'SAVEAS' = One Row in the '.CSV'...
=> Each time you want a new Row, fire a 'SAVEAS'... :idea:
(And the Content of '!EXTRACT' gets automatically emptied after each 'SAVEAS', you don't have to take care of it...)
- (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...
Post Reply