Why SEARCH does not return #EANF# ?

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
tudorbt
Posts: 1
Joined: Fri Sep 02, 2011 10:14 am

Why SEARCH does not return #EANF# ?

Post by tudorbt » Fri Sep 02, 2011 10:51 am

I'm using iMacros for FF and I made a small JS to do a loop, collect some data and export it to a CSV file.

All works fine except that I can't figure out why SEARCH does not return #EANF# if the data has not been found.

This is a real problem because it screws the columns in the CSV file. In the example below I am using one TAG and then three SEARCH to extract a Desciption, Address, Tel and Fax.

If the Description is not found then it returns an #EANF# making it a field in the CSV file. Otherwise, if the Address is not found and the Telephone is than the Telephone field enters in the Address column.

Code: Select all

...........
 macro += "TAG POS=1 TYPE=P ATTR=TXT:* EXTRACT=TXT" + jsLF;
 macro += "SEARCH SOURCE=REGEXP:\"Address:</span>\\s([^\<]+)\" EXTRACT=\"\$1\"" + jsLF;
 macro += "SEARCH SOURCE=REGEXP:\"Tel:</span>\\s([^\<]+)\" EXTRACT=\"\$1\"" + jsLF;
 macro += "SEARCH SOURCE=REGEXP:\"Fax:</span>\\s([^\<]+)\" EXTRACT=\"\$1\"" + jsLF;
...........
Finally, is there any way to test if the SEARCH has failed and update the EXTRACT variable with an empty field?

Thanks.
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Why SEARCH does not return #EANF# ?

Post by MattBell7 » Fri Sep 02, 2011 12:04 pm

what you could do would be fire the lines individually, then interrogate their response in your JS.

e.g.

iimPlay(Extract1)
x1 = iimGetLastExtract(1)
iimPlay(Extract2)
x2 = iimGetLastExtract(1)
iimPlay(Extract3)
x3 = iimGetLastExtract(1)
iimPlay(Extract4)
x4 = iimGetLastExtract(1)

then run this

iimSet("x1",x1)
iimSet("x2",x2)
iimSet("x3",x3)
iimSet("x4",x4)
macro = "CODE:SET !EXTRACT NULL"
macro += "ADD !EXTRACT x1"
macro += "ADD !EXTRACT x2"
macro += "ADD !EXTRACT x3"
macro += "ADD !EXTRACT x4"
macro += "SAVEAS TYPE=EXTRACT"
iimPlay(macro)
Tom, Tech Support
Posts: 3601
Joined: Mon May 31, 2010 4:59 pm

Re: Why SEARCH does not return #EANF# ?

Post by Tom, Tech Support » Sun Sep 11, 2011 12:12 pm

When a SEARCH expression fails to find a match, it returns error code -1320 (iMacros Browser & iMacros-IE) or error code -926 (iMacros for Firefox) regardless of whether you are just doing a search or an extraction. This is different from the TAG command, which will return #EANF# when doing an extraction and a match is not found.

Matt's suggestion works best as a workaround in this case. I'm going to raise this issue to the development team for further review.
Regards,

Tom, iMacros Support
msuresh
Posts: 3
Joined: Fri Oct 14, 2011 9:21 am

Re: Why SEARCH does not return #EANF# ?

Post by msuresh » Fri Oct 14, 2011 9:44 am

I am also Have the same problem . if any possible to extract the content to particular column like this.

TAG POS=1 TYPE=P ATTR=TXT:* EXTRACT=TXT {{!col1}}
SEARCH SOURCE=REGEXP:\"Address:</span>\\s([^\<]+)\" EXTRACT=\"\$1\" {{!col2}}
SEARCH SOURCE=REGEXP:\"Tel:</span>\\s([^\<]+)\" EXTRACT=\"\$1\" {{!col3}}
SEARCH SOURCE=REGEXP:\"Fax:</span>\\s([^\<]+)\" EXTRACT=\"\$1\" {{!col4}}

if the address is not found that column is return to blank
Post Reply