문제

I want crawler4j to visit pages in such a manner that they belong to domain in seed only. There multiple domains in seed. How can I do it?

Suppose I am adding seed URLs:

  • www.google.com
  • www.yahoo.com
  • www.wikipedia.com

Now I am starting the crawling but I want my crawler to visit pages (just like shouldVisit()) only in above three domains. Obviously there external links, but I want my crawler to restrict to these domains only. Sub-domain, sub-folders are okay, but not outside these domains.

도움이 되었습니까?

해결책 2

If you are trying to restrict the crawler to only urls with the same domains as the seed urls, then:

  1. Extract the domain names from the seed URLs.

  2. Write your crawler class (that extends WebCrawler) with a shouldVisit method to filter out any URLs whose domains are not in the set.

  3. Configure the controller, add the seeds and start it in the normal way ... as per the example here.

다른 팁

Posted on behalf of the OP:

Got the solution here : http://code.google.com/p/crawler4j/issues/detail?id=94#c1

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top