Scope
- 어떤 url을 크롤링할 것인지에 대한 규칙을 정해준다. 각 rule에 대한 Bean을 따로 만들고 이곳에서 참조하도록 설정하여도 되고, 이 Bean에 직접 설정해 주어도 된다.
<!-- SCOPE: rules for which discovered URIs to crawl; order is very
important because last decision returned other than 'NONE' wins. -->
<bean id="scope" class="org.archive.modules.deciderules.DecideRuleSequence">
<property name="logToFile" value="true" />
<property name="rules">
<list>
<!-- 모든 URL을 REJECT 하면서 시작 -->
<bean class="org.archive.modules.deciderules.RejectDecideRule" />
<!-- acceptSurts bean에서 설정한 규칙들은 ACCEPT -->
<ref bean="acceptSurts" />
<!-- 크롤링 시작점으로부터 link-hop-count가 설정 값 보다 크면 REJECT -->
<bean class="org.archive.modules.deciderules.TooManyHopsDecideRule">
<!-- <property name="maxHops" value="20" /> -->
</bean>
<!-- link-hop-count가 maxHops 보다 크더라도 transclusion의 경우이면 ACCEPT
<bean class="org.archive.modules.deciderules.TransclusionDecideRule">
<property name="maxTransHops" value="2" />
<property name="maxSpeculativeHops" value="1" />
</bean>
-->
<!-- 화이트 URL 설정하여 REJECT ( 즉, log에 남기지 않음 ) -->
<bean class="org.archive.modules.deciderules.surt.SurtPrefixedDecideRule">
<property name="decision" value="REJECT"/>
<property name="seedsAsSurtPrefixes" value="false"/>
<property name="surtsDumpFile" value="${launchId}/negative-surts.dump" />
<property name="surtsSource">
<bean class="org.archive.spring.ConfigString">
<property name="value">
<value>
# 이 곳에 화이트 URL 리스트를 적어준다.
</value>
</property>
</bean>
</property>
</bean>
<!-- 바로 위의 bean과 같은 역할이지만 surt rule이 아닌 정규식으로 화이트 URL 설정하여 줌 -->
<bean class="org.archive.modules.deciderules.MatchesListRegexDecideRule">
<property name="decision" value="REJECT"/>
<!-- <property name="listLogicalOr" value="true" /> -->
<!-- <property name="regexList">
<list>
</list>
</property> -->
</bean>
<!-- 의심스럽게 반복되는 Path-Segment를 가진 URL들을 REJECT 한다. -->
<bean class="org.archive.modules.deciderules.PathologicalPathDecideRule">
<!-- <property name="maxRepetitions" value="2" /> -->
</bean>
<!-- ...and REJECT those with more than threshold number of path-segments... -->
<bean class="org.archive.modules.deciderules.TooManyPathSegmentsDecideRule">
<!-- <property name="maxPathDepth" value="20" /> -->
</bean>
<!-- ...but always ACCEPT those marked as prerequisitee for another URI... -->
<bean class="org.archive.modules.deciderules.PrerequisiteAcceptDecideRule">
</bean>
<!-- ...but always REJECT those with unsupported URI schemes -->
<bean class="org.archive.modules.deciderules.SchemeNotInSetDecideRule">
</bean>
</list>
</property>
</bean>
- [property에 대한 설명]
- logToFile : scope.log 파일을 남길 것인지 남기지 않을 것인지에 대한 여부. scope.log 파일은 각 url이 어떤 rule에 의해 ACCEPT 혹은 REJECT 되었는지 기록한다.
- rules : 크롤링에 적용할 rule 목록을 아래 list에 나열함
- [각 rule과 rule들에 대한 property 설명]
모든 rule들은 org.archive.modules.deciderules.___ 의 경로에서 관리된다. 모든 rule에서 구분하는 link-hop의 종류들은 다음과 같다. # R - Redirect # E - Embed ( 이미지, iframe, css, js ) # X - Speculative embed (aggressive JavaScript link extraction) : javascript 코드에서 추출한 링크 # L - Link : 일반 링크 ( a 태그 같은 것들 ) # P - Prerequisite (such as DNS lookup or robots.txt) # I - Heritrix 3.1 부터는 자동으로, 긁어오도록 설정한 링크들. 꼭 소스에 필요한 부분들은 아니지만 관례상 존재할 것으로 추측되는 링크들 (such as /favicon.ico)
- RejectDecideRule : 모든 url을 REJECT 함
- TooManyHopsDecideRule : 크롤링 시작점으로부터 link-hop-count가 설정 값 보다 크면 REJECT.
> maxHops : L,E 등등 링크 종류 상관 없이 기본적으로 허용할 Hops 개수. - TransclusionDecideRule : transclusion이란 한 페이지에서 다른 페이지를 include 시키는 경우이다. 이 rule은 transclusion인지 아닌지를 판별하여 ACCEPT 해주는 부분이다.
> maxTransHops : 최소 1개 이상, maxTransHops 값 이하의 non-L-hop 개수를 가진 url을 ACCEPT한다.
> maxSpeculativeHops : X hop 개수의 최대값 설정 ( 너무 많은 X hop을 포함하고 있으면 transclusion으로서 실격이다. ) - HopsPathMatchesRegexDecideRule : ACCEPT/REJECT 할 특정 hops-path를 정규식으로 설정하여 준다.
> decision : ACCEPT/REJECT 중 하나 선택
> regex : 정규식 명시 - MatchesListRegexDecideRule : ACCEPT/REJECT 할 특정 URI 패턴을 설정하여 준다.
> decision : ACCEPT/REJECT 중 하나 선택
> listLogicalOr : 정규식 list 각 항목의 조건을 Or로 처리할 것인지에 대한 여부. 즉 이 값이 true이면 조건 중 하나만 일치해도 이 rule에 매칭 된다.
> regexList : list 태그 안에 설정할 정규식들을 하나하나 명시하여 준다. - PathologicalPathDecideRule : 연속적으로 반복되는 path-segment의 개수를 제한한다. (eg http://example.com/a/a/a/boo.html == 3 '/a' * segments)
> maxRepetitions : 제한할 반복 path-segment 개수 설정 - TooManyPathSegmentDecideRule : 전체 path-segments의 개수를 제한한다. path-segment는 '/'의 개수와 일치하며, 첫 //은 개수에 포함하지 않는다.
> maxPathDepth : 제한할 path-segments의 최대값 설정 - PrerequisiteAcceptDecideRule : 모든 Accept된 새로운 URI 들에 대해 dns, robots.txt들도 같이 ACCEPT 하도록 한다.
- SchemeNotInSetDecideRule : Heritrix에서 지원하는 URI scheme ( http, https, ftp, dns, whois ) 이 외의 URI scheme을 가진 URI는 REJECT 한다.
'212.Heritrix_설정파일 > 04. SCOPE' 카테고리의 다른 글
[Heritrix/crawler-beans.cxml]acceptSurts (0) | 2016.07.26 |
---|