Macro cannot find a #EANF# extract to stop on

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Macro cannot find a #EANF# extract to stop on

by sylviewp on Mon Sep 23, 2013 10:30 pm

Hiya,
I have looked in the iOpus forum for an answer these last few days but all I find is references to using the iimGetLastExtract which, on its own, will not work for me. I hope someone can help.
I am running a pretty basic vba script to scrape rows of data into a csv file.
Normally, the macro would terminate when it reaches the last page however, for this particular URL, it just won't work.
It seems that it is not finding an #EANF# to bail out on because it is continually scraping the last page that actually has some content on it.
It keep scraping the last entries over and over again with no end in sight :)
I guess I need to add a second variable to keep track of the imGetLastExtract from the previous page scrape. and then compare the current page against this new variable. If they are the same then I can probably guess it is the last page and close the script.

That sounds very easy on paper but am really not sure how to set up this new variable. Any suggestion is really appreciated. Thanks a lot. Sylvie


Sub iMacroHandlerB()
Dim iim1, iret, i
Dim Pageloop

'Start iMacro Browser
Set iim1 = CreateObject("imacros")
iret = iim1.iimInit("", False)

'Run the Initial Macro
iret = iim1.iimPlay("Loop_Initial")

i = 1
Do
i = i + 1
iret = iim1.iimset("Pageloop", i)
iret = iim1.iimPlay("Strip")
If (iim1.iimGetLastExtract()) = "#EANF#" Then
iret = iim1.iimExit()
End If
Loop
End Sub

Loop_Initial:

VERSION BUILD=6801021
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.insight.com/insightweb/search#searchResults#page=1#inStockFilterType=BothInStockAndOutOfStock#noCLP=true#shown=10#shownFlag=true#searchText=%22hp%22%2C%22storageworks%20nas%22
SET !EXTRACT_TEST_POPUP NO
WAIT SECONDS=5

Strip:

VERSION BUILD=6801021
TAB T=1
TAB CLOSEALLOTHERS
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
TAG POS=1 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=2 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=2 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=3 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=3 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=4 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=4 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=5 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=5 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=6 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=6 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=7 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=7 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=8 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=8 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=9 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=9 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=10 TYPE=DIV ATTR=CLASS:productTitle&&TXT:*&&ID:prodTitle EXTRACT=TXT
TAG POS=10 TYPE=DIV ATTR=CLASS:productDescription&&TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=INSIGHT_STREET_HP.TXT
TAG POS=1 TYPE=A ATTR=TXT:{{Pageloop}}
sylviewp
 
Posts: 1
Joined: Mon Sep 23, 2013 10:11 pm

Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 2 guests

-->