CandidateScoper

  • 앞서 정의한 scope rule 들을 각 URI에 적용하는 processor.
    Pass-in URI를 모두 candidate로 놓고, scope를 벗어나는 URI에 대해선 fetch_status를 negative로 변경하여 작업이 끝날 때 까지 skip한다.

기존 설정 값

 <!-- first, processors are declared as top-level named beans -->
 <bean id="candidateScoper" class="org.archive.crawler.prefetch.CandidateScoper">
 </bean>


Posted by Righ
,


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에 대한 설명]
    1. logToFile : scope.log 파일을 남길 것인지 남기지 않을 것인지에 대한 여부. scope.log 파일은 각 url이 어떤 rule에 의해 ACCEPT 혹은 REJECT 되었는지 기록한다.
    2. 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)

    1. RejectDecideRule : 모든 url을 REJECT 함
    2. TooManyHopsDecideRule : 크롤링 시작점으로부터 link-hop-count가 설정 값 보다 크면 REJECT.
      > maxHops : L,E 등등 링크 종류 상관 없이 기본적으로 허용할 Hops 개수.
    3. TransclusionDecideRule : transclusion이란 한 페이지에서 다른 페이지를 include 시키는 경우이다. 이 rule은 transclusion인지 아닌지를 판별하여 ACCEPT 해주는 부분이다.
      > maxTransHops : 최소 1개 이상, maxTransHops 값 이하의 non-L-hop 개수를 가진 url을 ACCEPT한다.
      > maxSpeculativeHops : X hop 개수의 최대값 설정 ( 너무 많은 X hop을 포함하고 있으면 transclusion으로서 실격이다. )
    4. HopsPathMatchesRegexDecideRule : ACCEPT/REJECT 할 특정 hops-path를 정규식으로 설정하여 준다.
      > decision : ACCEPT/REJECT 중 하나 선택
      > regex : 정규식 명시
    5. MatchesListRegexDecideRule : ACCEPT/REJECT 할 특정 URI 패턴을 설정하여 준다.
      > decision : ACCEPT/REJECT 중 하나 선택
      > listLogicalOr : 정규식 list 각 항목의 조건을 Or로 처리할 것인지에 대한 여부. 즉 이 값이 true이면 조건 중 하나만 일치해도 이 rule에 매칭 된다.
      > regexList : list 태그 안에 설정할 정규식들을 하나하나 명시하여 준다.
    6. PathologicalPathDecideRule : 연속적으로 반복되는 path-segment의 개수를 제한한다. (eg http://example.com/a/a/a/boo.html == 3 '/a' * segments)
      > maxRepetitions : 제한할 반복 path-segment 개수 설정
    7. TooManyPathSegmentDecideRule : 전체 path-segments의 개수를 제한한다. path-segment는 '/'의 개수와 일치하며, 첫 //은 개수에 포함하지 않는다.
      > maxPathDepth : 제한할 path-segments의 최대값 설정
    8. PrerequisiteAcceptDecideRule : 모든 Accept된 새로운 URI 들에 대해 dns, robots.txt들도 같이 ACCEPT 하도록 한다.
    9. 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
Posted by Righ
,

AcceptSurts

  • Scope에서 참조하는 Bean이다. 이 Bean에서 설정해준 surt rule을 따르는 URL은 크롤링한다. 크롤링 규칙을 Surt Rule로 설정해 주고 싶을 때 이 Bean을 사용한다.

기존 설정 값

 <bean id="acceptSurts" class="org.archive.modules.deciderules.surt.SurtPrefixedDecideRule">
  <!-- <property name="decision" value="ACCEPT"/> -->
  <!-- <property name="seedsAsSurtPrefixes" value="true" /> -->
  <!-- <property name="alsoCheckVia" value="false" /> -->
  <!-- <property name="surtsSourceFile" value="" /> -->
  <!-- <property name="surtsDumpFile" value="${launchId}/surts.dump" /> -->
  <!-- <property name="surtsSource">
        <bean class="org.archive.spring.ConfigString">
         <property name="value">
          <value>
           # example.com
           # http://www.example.edu/path1/
           # +http://(org,example,
          </value>
         </property> 
        </bean>
       </property> -->
 </bean>
  • [property에 대한 설명]
    1. decision : 아래의 설정 룰에 매칭되는 url을 Accept할 것인지 혹은 Reject 할 것 인지 여부
    2. seedsAsSurtPrefixes : 위에서 seed로 설정 해준 url을 Surt prefix rule로 설정할 것인지에 대한 여부. Heritrix 고도화를 위한 테스트 이력 no 3. 참조
    3. alsoCheckVia : Via 링크가 Surt규칙에 매칭될 경우에도 Accept할 것인지에 대한 여부. 만약 example.com 사이트를 크롤링할 때 example.com/a.html에 외부로 향하는 링크가 있다고 한다면, example.com/a.html이 Surt 규칙에 부합하므로 이 외부 링크를 ACCEPT하고 로그에 남김과 동시에 큐에 Push한다. Heritrix 고도화를 위한 테스트 이력 no 4. 및 acceptSurts_alsoCheckVia 테스트 로그 분석 참조
    4. surtsSourceFile : 여기에 파일 경로를 적어줄 경우 surt 규칙들을 파일로 관리할 수 있다.
    5. 그 아래 주석 처리 된 부분은 모두 Surt 규칙을 파일로 또는, 직접 설정해 주는 부분임


'212.Heritrix_설정파일 > 04. SCOPE' 카테고리의 다른 글

[Heritrix/crawler-beans.cxml]scope  (0) 2016.07.26
Posted by Righ
,

Seeds

  • lognerOverrides에서 세팅 해준 설정 값의 세부 사항들을 세팅해준다.

기본 세팅 값

 <!-- SEEDS: crawl starting points 
      ConfigString allows simple, inline specification of a moderate
      number of seeds; see below comment for example of using an
      arbitrarily-large external file. -->
 <bean id="seeds" class="org.archive.modules.seeds.TextSeedModule">
     <property name="textSource">
      <bean class="org.archive.spring.ConfigString">
       <property name="value">
        <value>
# [see override above]
        </value>
       </property>
      </bean>
     </property>
<!-- <property name='sourceTagSeeds' value='false'/> -->
<!-- <property name='blockAwaitingSeedLines' value='-1'/> -->
 </bean>

다른 설정 방법
property의 하위 bean의 참조 클래스를 ConfigFile로 하고 참조할 file명을 써주면 file 단위로 seed들을 관리 할 수 있다.

<!-- SEEDS ALTERNATE APPROACH: specifying external seeds.txt file in
      the job directory, similar to the H1 approach. 
      Use either the above, or this, but not both. -->

 <bean id="seeds" class="org.archive.modules.seeds.TextSeedModule">
  <property name="textSource">
   <bean class="org.archive.spring.ConfigFile">
    <property name="path" value="seeds.txt" />
   </bean>
  </property>
  <property name='sourceTagSeeds' value='false'/>
  <property name='blockAwaitingSeedLines' value='-1'/>
 </bean>
  • [property에 대한 설명]
    1. textSouce : longerOverrides 참조
    2. sourceTagSeeds : 크롤링할 seed가 여러개인 경우, log파일에 크롤된 url이 어떤 seed에서 크롤링 된 것인지를 나타내는 sourceTagSeeds 값이 저장된다. true로 설정 해줌
    3. blockAwaitingSeedLines : 크롤링 시작시 seed를 몇 개 로딩할 것인지 설정 해 준다. '-1'일 경우 all. seed list가 거대한 경우, scope 규칙이 모든 seed를 읽는다는 것에 의존하지 않은 경우 이 값을 설정해 준다.


Posted by Righ
,

Metadata

  • simpleOverrides에서 세팅 해준 설정 값의 세부 사항들을 세팅해준다.

기본 설정 값

  <!-- CRAWL METADATA: including identification of crawler/operator -->
 <bean id="metadata" class="org.archive.modules.CrawlMetadata" autowire="byName">
       <property name="operatorContactUrl" value="[see override above]"/>
       <property name="jobName" value="[see override above]"/>
       <property name="description" value="[see override above]"/>
  <!-- <property name="robotsPolicyName" value="obey"/> -->
  <!-- <property name="operator" value=""/> -->
  <!-- <property name="operatorFrom" value=""/> -->
  <!-- <property name="organization" value=""/> -->
  <!-- <property name="audience" value=""/> -->
  <!-- <property name="userAgentTemplate" 
         value="Mozilla/5.0 (compatible; heritrix/@VERSION@ +@OPERATOR_CONTACT_URL@)"/> -->

 </bean>


  • [property에 대한 설명]
    1. operatorContactUrl : simpleOverrides 참조
    2. jobName : simpleOverrides 참조
    3. description : simpleOverrides 참조
    4. robotsPolicyName : robots.txt의 규칙을 준수할 것인지에 대한 여부.(obey=classic,ignore)
    5. 아래 주석처리 된 부분은 작업자의 이름, 연락처, 회사 등


Posted by Righ
,