unable to loop a scraping session - please help
please somebody help, my loop script is in the root directory and contains
for( int i = 1; i < 10; i++ )
{
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "Guys" );
{
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "Guys" );
runnableScrapingSession.setVariable( "ID", String.valueOf(i) );
runnableScrapingSession.setDoLazyScrape( false );
runnableScrapingSession.scrape( "Guys" );
}
but when i try to run this script it says>
[quote]Script: The Loop
Error Message:
Error in method invocation: Method scrape( java.lang.String ) not found in class'com.screenscraper.scraper.RunnableScrapingSession' : at Line: 8.[/quote]
i have already removed the basic version and tried the pro trial - but the message is the same
thanks
unable to loop a scraping session - please help
Scott,
You info was extremely helpful. I had gone through the tutorials more than once, but was unclear on where I should be executing the loop and how. I can now loop through as many pages as I need. Thanks!
Sincerely,
John
unable to loop a scraping session - please help
jziebro,
I can't think of any reason why you would want to do this. Really, the only reason to use RunnableScrapingSession class is if you want to share data between two different scraping sessions. It doesn't look like that's what you're after.
If you have not, I recommend going through the tutorials so you can understand better the fundamentals of how screen-scraper works.
If, perhaps, what you're wanting to do is simply run a scrapeable file iteratively, passing a new value for each loop, then can I recommend that you use a script that looks like this and call that script from your "Security" scrapeable file, "After file is scraped".
{
//Add the next value as a session variable
session.setVariable( "ID", String.valueOf(i) );
//Run the scrapeable file
session.scrapeFile("Company Info");
}
If you want to access the value of ID from your "Company Info" scrapeable file's parameters tab don't forget to reference it like so...
~#ID#~
Hope this helps and please take the time to go through our tutorials if you haven't yet.
Thanks,
Scott
unable to loop a scraping session - please help
I installed the pro version and have been working with it instead.
unable to loop a scraping session - please help
jziebro,
Reading back on your original post I noticed that you said you're using the basic edition. If so, RunnableScrapingSession only work in professinal and enterprise editions.
-Scott
unable to loop a scraping session - please help
Also, is there a way to call a specific request in the scrape session? Lets say I just want to call the Security request.
runnableScrapingSession.scrape();
Thanks again!
unable to loop a scraping session - please help
Scott,
[img]http://johnziebro.com/example.jpg[/img]
Can you tell me exactly where to add the script? Should I just run the script (1) add it to the whole session (2) or just the part that needs to be looped (3).
Security logs in, Company info should pull up each company and extract their mailing info. The sequence was inverted for Security and Company when I created the screenshot, security should happen once, then Company Info should repeat.
Running the script doesnt seem to do anything. Adding it to (3) crashes the program and I have to reboot and wipe the database.
{
//Here you declare the object
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "RDN SCRAPE" );
//Here you're adding session-specific values
runnableScrapingSession.setVariable( "ID", String.valueOf(i) );
//Here you just tell it to go...
runnableScrapingSession.scrape();
}
Maybe a definitive, step by step simple example of creating a programatic loop would be helpful.
Thanks,
John
unable to loop a scraping session - please help
jziebro,
This could happen if somehow you have this script calling itself. Make sure that there is never an occasion where your calling this script or perhaps the scrapeable file that invokes this script after it is initially called. This script should be the place that instantiates or begins the recursion but should never be called again from within what it sets going.
Does that make sense for your situation?
-Scott
unable to loop a scraping session - please help
Any ideas as to why this code would send screen scraper into an infinite loop, forcing me to manually quit it, and then have to use the backup database?
unable to loop a scraping session - please help
jziebro,
You do need to pass it the name of your scraping session when declaring the RunnableScrapingSession object but not when calling the scrape method.
So, just add the name of your scraping session with quotes inside the parenthesis for this line.
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession();
-Scott
unable to loop a scraping session - please help
Based on this post, I am also trying to get a loop working. Can you review the following info and point out my mistake? Thanks!! I am using the basic version.
The url is (domain removed): www.website.com/mod02_SA/contact_management/contact_details.php?cn=~#ID#~
The script is set to interpreted Java.
{
//Here you declare the object
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession();
//Here you're adding session-specific values
runnableScrapingSession.setVariable( "ID", String.valueOf(i) );
runnableScrapingSession.setDoLazyScrape( false );
//Here you just tell it to go...
runnableScrapingSession.scrape();
}
This is the error I receive:
An error occurred while processing the script: Loop
The error message was: Constructor error: Can't find default constructor for: class com.screenscraper.scraper.RunnableScrapingSession : at Line: 4.
Data Extraction: Preliminary URL: http://ww.website.com/mod02_SA/contact_management/contact_details.php?cn=~#ID#~
unable to loop a scraping session - please help
amazing, thank you very much for the instant support!!
unable to loop a scraping session - please help
a4chitect,
When calling runnableScrapingSession.scrape() you don't need to pass in the name of the scraping session. That parameter gets established when you declare the object.
{
//Here you declare the object
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "Guys" );
//Here you're adding session-specific values
runnableScrapingSession.setVariable( "ID", String.valueOf(i) );
runnableScrapingSession.setDoLazyScrape( false );
//Here you just tell it to go...
runnableScrapingSession.scrape();
}
-Scott
trying a different approach
[b]trying a different approach[/b]
trying to call the script below from the file scraper itself
"after file is scraped"
session.setVariable( "ID" ) = String.valueOf(Integer.parseInt(session.getVariable( "ID" )) + 1);
but without anymore luck
[quote]The error message was: Error in method invocation: Method setVariable( java.lang.String ) not found in class'com.screenscraper.scraper.ScrapingSession' : at Line: 1.[/quote]
ideas anyone>?