Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to count the mount of urls and collect urls? #111

Open
Mr-Vincent opened this issue Jan 15, 2016 · 2 comments
Open

How to count the mount of urls and collect urls? #111

Mr-Vincent opened this issue Jan 15, 2016 · 2 comments

Comments

@Mr-Vincent
Copy link

I can override the method "onBeforeExit()" to collect urls the program crawled.But the WebCrawler instance will destoryed when the current thread was dead and the variable for saving url list defined in subclass of WebCrawler would be reset so I cannot collect the urls that the program crawled.
Could u give me some demos to resolve my puzzle?
BTW,I am a java leaner,thx 4 providing such a great open-source project!

@shinbuiev
Copy link

public class MyCrawler extends WebCrawler {
public static AtomicInteger linkCounter = new AtomicInteger(); //or use links.size()
static List links = new CopyOnWriteArrayList();
...
}
@OverRide
public void handlePageStatusCode(final WebURL webUrl, int statusCode, String statusDescription) {
linkCounter.incrementAndGet();
links.add(webUrl);
}

so you can count the amount of urls and collect them to collection.

@Chaiavi
Copy link
Contributor

Chaiavi commented Jan 19, 2016

Thanks.

This one can be closed

On Fri, Jan 15, 2016 at 1:33 PM, shinbuiev notifications@github.com wrote:

public class MyCrawler extends WebCrawler {
public static AtomicInteger linkCounter = new AtomicInteger(); //or use
links.size()
static List links = new CopyOnWriteArrayList();
...
}
@OverRide https://github.com/Override
public void handlePageStatusCode(final WebURL webUrl, int statusCode,
String statusDescription) {
linkCounter.incrementAndGet();
links.add(webUrl);
}

so you can count the amount of urls and collect them to collection.


Reply to this email directly or view it on GitHub
#111 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants