Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple IE events in the task manager
Message
 
To
02/07/2012 14:37:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01547488
Message ID:
01547499
Views:
49
>>>>>Hi folks. With the help of the UT I have constructed a bot to scoop text from websites and store the result in a table for later access.
>>>>>
>>>>>When I do a run (until prg crash) multiple (30 or so) internet explorer objects are created and can be seen in the task manager. I am trying to release/destroy and recreate the object to prevent the build up of objects after use in the prg as it loops through a table of URLs. However, the problem persists. Could I have a little help solving this one, please?
>>>>
>>>>How do you create an IE instance?
>>>
>>>
>>>Thanks - Here it is.
>>>
>>>lox=CREATEOBJECT('internetexplorer.application')
>>
>>OK,
>>but what is the rest of the code :-)
>>Where is the loop?
>
>Here is the whole thing.
>SET DEFAULT TO C:\netscrape
>CLEAR
>CLOSE TABLES ALL
>USE results
>*DELETE ALL < DO NOT DELETE OR PACK AS DATES NEED TO BE USED TO SHOW TRENDS
>*PACK
>PUBLIC lcTEXT,cSearchExpression,Captured,Caught1,Caught2,nStartReplacement,EntityName,Flagg,hits
>PUBLIC tempitem,Across,GraphValue,TheScore,Hunt,PreviousCatch,TheTensionValue,TensePhrase,Tempword
>PUBLIC SearchLoops
>SearchLoops = 0
>hits = 0
>Tempword = ""
>WordPointer = 0
>Caught3 = ""
>Caught4 = "ERROR"
>Flagg = 0
>TensePhrase = ""
>TheTensionValue = 0
>PreviousCatch = ""
>tempitem = ""
>TheScore = 0
>GraphValue = 0
>lcTEXT = ""
>EntityName = ""
>cSearchExpression = ""
>Across = 0
>Captured = DATE()
>Caught1 = 0
>Caught2 = ""
>nOccurrence = 0
>nStartReplacement = 0
>Hunt = 0
>USE URLS IN 1
>USE results IN 2
>SET DELETED ON
>IF TYPE('lox')#'O'
>	lox=CREATEOBJECT('internetexplorer.application')
>ENDIF
>SELECT URLS
>COUNT TO URLcount
>? URLcount
>
>lox.VISIBLE=.F.
>********** Find what we want and save it **********
>SCAN
>	? RECNO()
>	lcURL = Location
>	lcURL = ALLTRIM(TRANSFORM(lcURL))
>	lnTime=200 && 100 = 1 minute
>	lox.NAVIGATE(lcURL)
>	lox.VISIBLE=.F.
>	WAIT 'Navigating!' WINDOW NOWAIT
>
>******************
>	IF !NavComplete(lox,lnTime)
>		??CHR(7)
>		RELEASE lox
>		SKIP
>		lcTEXT = "ERROR RECORDED"
>		? "ERROR RECORDED"
>		WAIT 'Timeout failed!' WINDOW NOWAIT
>
>		RETURN
>	ENDIF
>	lcTEXT = lox.DOCUMENT.body.innertext
>	Caught2 = UPPER(lcTEXT)
>*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^
>* STREXTRACT(cSearchExpression, cBeginDelim [, cEndDelim [, nOccurrence
>*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^
>	IF LEN(ALLTRIM(Caught2)) > 100
>		SELECT results
>		APPEND BLANK
>		REPLACE results.Captured WITH DATE()
>		REPLACE results.sitetext WITH Caught2
>		Caught2 = ""
>	ENDIF
>	lox=CREATEOBJECT('internetexplorer.application')
>	SELECT URLS
>ENDSCAN
>CLOSE TABLES ALL
>? "                                                                                                                                    THE RUN IS COMPLETE"
>CANCEL
>**************************************************
>
>FUNCTION NavComplete
>LPARA toIE, tnTimeout
>lnTimeout=IIF( TYPE("tnTimeout")="N",tnTimeout ,60 ) && 60
>lnTimeElapsed=0
>lnStartSeconds=SECONDS()
>DO WHILE .T.
>	IF toIE.ReadyState=4 AND !toIE.Busy
>		DO WHILE .T.
>			IF toIE.DOCUMENT.ReadyState="complete"
>				RETURN .T.
>			ENDIF
>			IF (SECONDS()-lnStartSeconds)>lnTimeout
>*			DELETE &&
>				RETURN .F.
>			ENDIF
>		ENDDO
>	ENDIF
>	IF (SECONDS()-lnStartSeconds)>lnTimeout
>		RETURN .F.
>	ENDIF
>ENDDO
>ENDFUNC
Remove this line " lox=Createobject('internetexplorer.application')" from loop.
Also put everywhere you exit this routine:
lox.Quit()
lox = NULL
RELEASE lox
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform