Skip Output if File Exists and Looping

Hello Support:

I’m scraping a dynamic webpage, whereby real estate properties are added throughout the day. I would like to output the data of the new properties as they are uploaded throughout the day. The name of the output file will be the address of the property. I don’t want to overwrite the existing file if a property has been has been written already. Since there will be properties uploaded to the webpage through the course of the day I want Screen Scraper to loop throughout the day.

The Sequence is as follows:

1. Property ID File. The webpage is dynamic and adds real estate properties (Properties) throughout the day.
a. Token: Scrape Property ID
b. Script: Scrape Property Detail File “After each pattern match”
2. Property Detail File.
a. Token: Scrape Property Details
b. Script: Write “After each pattern match”
3. Write Script
a. Name of file is address of property
b. Scrape “More Details File”
4. More Details File.
a. Token: Scrape Property Details
b. Script: Write “After each pattern match”

The basics of the Write script are as follows:

outputFile = "C:/Documents and Settings/Me/Desktop/XXX Search/" + session.getVariable( "ADDRESS" ) + ".csv";
//Error catching.
try
{
//Set-up file to be written.
File file = new File ( outputFile );
fileExists = file.exists();

//Open up the file to be appended.
out = new FileWriter( file, true );
session.log( "Writing data to a file." );
 etc.

At the end of the write script is as follows:

session.scrapeFile( "More Details File" );

I’m not sure how to edit the above script so that it does not append or rewrite if the written file exists. In addition, if the file exists I do not want it to scrape the “More Details File.” Also, I want to loop the scraping session in the workbench mode but I couldn’t find a script on the forum for looping an entire scraping session.

Thanks,

Adrian

Something like: outputFile =

Something like:

outputFile = outputPath + session.getv("ADDRESS") + ".csv";
File file = new File(outputFile);
if (!file.exists())
{
        session.scrapeFile("Detials");
}
else
{
        session.log("Already have this one so skipping");
}

?