$20 via PayPal if you can solve my problems - Next link, CvsWriter

Hey

I have a couple problems I can't get past and after playing around with, and comparing with the tutorials, the program crashes ... I GIVE UP!

I'd like to move past these bumps and start to enjoy SS.. so I'll send $20 via paypal to whomever can solve my problems.

Problem 1) I'm trying to scrape bing searches of wikipedia (site:wikipedia.org *keyword), and I was suggested to use the following script to get past the intervals of 10 with bing pages:

makeNum(num)
{
if (num!=null)
{
num = String.valueOf(num);
num = num.replaceAll("\\D", "");
if (num.length()>0)
{
num = Integer.parseInt(num);
}
else
num = 0;
}
else
num = 0;

return num;
}

totalResults = makeNum(dataRecord.get("TOTAL_RECORDS"));
resultsPerPage = 10;
pages = totalResults/resultsPerPage;
if (totalResults%resultsPerPage>0)
pages++;

for (i=2; i<=pages; i++)
{
session.setVariable("PAGE", i);
session.log("STARTING PAGE " + i + " OF " + pages);
session.scrapeFile("Next page");
}

I modified it to this:
(script name: Search Results ScrapeableFile)

// If using an offset, this number should be the first search results page's offset, be it 0 or 1.
int initialOffset = 1;

// ... and this number is the amount that the offset increases by each
// time you push the "next page" link on the search results.
int offsetStep = 10;

String fileToScrape = "Search Results ScrapeableFile Name";

/* Generally no need to edit below here */

hasNextPage = "true"; // dummy value to allow the first page to be scraped
for (int currentPage = 1; hasNextPage != null; currentPage++)
{
// Clear this out, so the next page can find its own value for this variable.
session.setVariable("HAS_NEXT_PAGE", null);
session.setVariable("PAGE", currentPage);
session.setVariable("OFFSET", (currentPage - 1) * offsetStep + initialOffset);
session.scrapeFile(fileToScrape);
hasNextPage = session.getVariable("HAS_NEXT_PAGE");
}

However this is the log result:
Search Results ScrapeableFile Name: Applying extractor pattern: Next link
Search Results ScrapeableFile Name: Extracting data for pattern "Next link"
Search Results ScrapeableFile Name: The following data elements were found:
Next link--DataRecord 0:
KEYWORD=site%3awikipedia.org+leather
Storing this value in a session variable.
HAS_NEXT_PAGE=21
PAGE=5286.1
Search Results ScrapeableFile Name: Processing scripts after a pattern application.
Search Results ScrapeableFile Name: Processing scripts once if pattern matches.
Processing script: "Next page"
Scraping file: "Search Results ScrapeableFile Name"
Search Results ScrapeableFile Name: Preliminary URL: http://www.bing.com/search
Search Results ScrapeableFile Name: Using strict mode.
Search Results ScrapeableFile Name: Resolved URL: http://www.bing.com/search?q=site%3Awikipedia.org+leather&go=&filt=lf&first=11&FORM=PORE
Search Results ScrapeableFile Name: Sending request.
Search Results ScrapeableFile Name: Processing scripts before all pattern applications.
Search Results ScrapeableFile Name: Applying extractor pattern: Product details link
Search Results ScrapeableFile Name: Extracting data for pattern "Product details link"
Search Results ScrapeableFile Name: The following data elements were found:

Problem 2)
I'm trying to scrape an e-comm site, but again the next link wont activate the page 2 SERP..
Here's the log:

Search results: Processing scripts before all pattern applications.
Search results: Applying extractor pattern: Next link
Search results: Extracting data for pattern "Next link"
Search results: The following data elements were found:
Next link--DataRecord 0:
KEYWORD=Harness
Storing this value in a session variable.
PAGE=2
Search results: Processing scripts after a pattern application.
Next link--DataRecord 1:
KEYWORD=Harness
Storing this value in a session variable.
PAGE=2
Search results: Processing scripts after a pattern application.
Search results: Processing scripts once if pattern matches.
Processing script: "Scrape the search results"
Scraping file: "Search results"
Search results: Preliminary URL: *omitted*/shop/advanced_search_result.php
Search results: Using strict mode.
Search results: Resolved URL: *omitted*/shop/advanced_search_result.php?keywords=Harness&page=1
Search results: Sending request.
Search results: Processing scripts before all pattern applications.
Search results: Applying extractor pattern: Details page
Search results: Extracting data for pattern "Details page"

Problem 3 (final one) with CvsWrite.. Here's the script i pasted together (sloppily) from the tutorials, but it's creating a new yet empty .cvs file for each details page.

FileWriter out = null;

try
{
session.log( "Writing data to a file." );

// Open up the file to be appended to.
// Import class
import com.screenscraper.csv.*;

// Retrieve CsvWriter from session variable
writer = session.getv( "WRITER" );
// Create CsvWriter with timestamp
CsvWriter writer = new CsvWriter("output.csv", true);

// Create Headers Array
String[] header = {"TITLE", "MEASUREMENTS"};

// Set Headers
writer.setHeader(header);

// Save in session variable for general access
session.setVariable( "WRITER", writer);
// Write dataRecord to the file (headers already set)
writer.write(dataRecord);

// Flush record to file (write it now)
writer.flush();
// Close up the file.
// Retrieve CsvWriter from session variable
writer = session.getv( "WRITER" );

// Write buffer and close file
writer = session.getv( "WRITER" );

// Write buffer and close file
writer.close();
}

That's a lot of info, but it should be a quick $20 for someone in the know.

Post in the forum so it'll help the next person stuck. We'll communicate in the thread and the first person to get my SS working gets the $20.

Fair enough?