saveAllObjects

saveAllObjects ( int|default:1 _saveAllXiterations , string _pathFile ) : boolean

Save all global variables. It will be reloaded in the next analysis with loadAllObjects. It is useful for long analysis where it can have an interruption.
Returns true if variables are saved.
Variables to save must be serializable and contains just serializable objets. If you create your own class, use the structure "class MyClass implements Serializable { ... }"

Example


loadAllObjects() //load all previous variables (linksToVisit and linksVisited)

if(!isGlobalVariableExists("linksToVisit")) //for first run
{
linksToVisit = ["http://target-site.com"]
linksVisited = []
}

//crawling
def analyzePageAndAddLinks()
{
myLink = remove(linksToVisit, 0)
if(!arrayContains(linksVisited, myLink))
{
.... //do something

saveAllObjects(30) //each 30 links all variables are saved (linksToVisit and linksVisited especially)
}

linksVisited.add(myLink)
saveAllObjects()
}

while(linksToVisit) analyzePageAndAddLinks() //crawl if there are links to visit


See also

loadAllObjects
isGlobalVariableExists

Parameters

_saveAllXiterations (optional)

Allows to skip this function sometimes (it can accelerate the iteration, because it not save each time)

_pathFile (optional)

You can indicate a special path on your disk to save all variables. Else it is saved in the folder savedObject of Grimport Crawler.