How to scrape just 'top ten' results
I have a need for a 'top ten' list scraped from a golf leaderboard. At the moment I'm scraping the entire field which while only 70 records or so seems wasteful. Is there a way of limiting the number of records scraped to just the top ten?
FYI I'm using the 'write to csv' script given at http://community.screen-scraper.com/script_repository/Write_to_CSV.
Thanks,
Ian
Are all the results on one
Are all the results on one page, or are you looking to reduce the number of pages you hit and still get the top 10?
All the results are on one
All the results are on one page
In that case you'll have an
In that case you'll have an extractor to match each item. The extractor will still match it every time it appears, but you'll make your write to file script "run after pattern is applied", and it will look like
outputFile = "output/" + session.getName() + ".csv";v
out = new FileWriter(outputFile, true);
for (i=0; i<10; i++)
{
dr = dataSet.getDataRecord(i);
out.write(dr.get("TOKEN1") + ",");
out.write(dr.get("TOKEN2") + ",");
out.write( "\n" );
}
out.close();
That will write out just the top 10
Thanks for your reply
Thanks Jason for your help, but I'm afraid my understanding of the process is very limited and I can't make it work. I was hoping it would be an easy process - I'll just stick to what currently works for me and forget about my 'Top Ten'.
cheers
Ian