mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-25 15:16:24 +00:00
[HER-1799] H3: expand 'inferred' URI options to optionally include root-page (/)
* ExtractorHTTP.java
add property inferRootPage; if true (not the default), always consider '/' inferred from all HTTP(S) URIs
* Hop.java, LinkContext.java
add new hop-type 'I' for inferred URIs; add corresponding LinkContext
* ExtractorImpliedURI.java
use new 'I'nferred types
This commit is contained in:
@@ -39,6 +39,16 @@ public class ExtractorHTTP extends Extractor {
|
||||
public ExtractorHTTP() {
|
||||
}
|
||||
|
||||
/** should all HTTP URIs be used to infer a link to the site's root? */
|
||||
boolean inferRootPage = false;
|
||||
public boolean getInferRootPage() {
|
||||
return inferRootPage;
|
||||
}
|
||||
public void setInferRootPage(boolean inferRootPage) {
|
||||
this.inferRootPage = inferRootPage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean shouldProcess(CrawlURI uri) {
|
||||
if (uri.getFetchStatus() <= 0) {
|
||||
@@ -57,7 +67,10 @@ public class ExtractorHTTP extends Extractor {
|
||||
addHeaderLink(curi, method.getResponseHeader("Content-Location"));
|
||||
|
||||
// try /favicon.ico for every HTTP(S) URI
|
||||
addOutlink(curi, "/favicon.ico", LinkContext.EMBED_MISC, Hop.EMBED);
|
||||
addOutlink(curi, "/favicon.ico", LinkContext.INFERRED_MISC, Hop.INFERRED);
|
||||
if(getInferRootPage()) {
|
||||
addOutlink(curi, "/", LinkContext.INFERRED_MISC, Hop.INFERRED);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addHeaderLink(CrawlURI curi, Header loc) {
|
||||
|
||||
@@ -132,8 +132,8 @@ public class ExtractorImpliedURI extends Extractor {
|
||||
try {
|
||||
UURI src = curi.getUURI();
|
||||
UURI target = UURIFactory.getInstance(implied);
|
||||
LinkContext lc = LinkContext.SPECULATIVE_MISC;
|
||||
Hop hop = Hop.SPECULATIVE;
|
||||
LinkContext lc = LinkContext.INFERRED_MISC;
|
||||
Hop hop = Hop.INFERRED;
|
||||
Link out = new Link(src, target, lc, hop);
|
||||
curi.getOutLinks().add(out);
|
||||
numberOfLinksExtracted.incrementAndGet();
|
||||
|
||||
@@ -48,8 +48,13 @@ public enum Hop {
|
||||
/**
|
||||
* Referral/redirect links, like header 'Location:' on a 301/302 response.
|
||||
*/
|
||||
REFER('R');
|
||||
REFER('R'),
|
||||
|
||||
/**
|
||||
* Inferred/implied links -- not necessarily literally in the source
|
||||
* material, but deduced by convention.
|
||||
*/
|
||||
INFERRED('I');
|
||||
|
||||
/** The hop character for logs. */
|
||||
private char hopChar;
|
||||
|
||||
@@ -28,8 +28,9 @@ import java.io.Serializable;
|
||||
* @author pjack
|
||||
*/
|
||||
public abstract class LinkContext implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
/** Class for representing handy default LinkContext values. */
|
||||
private static class SimpleLinkContext extends LinkContext {
|
||||
|
||||
@@ -65,6 +66,12 @@ public abstract class LinkContext implements Serializable {
|
||||
final public static LinkContext SPECULATIVE_MISC
|
||||
= new SimpleLinkContext("=SPECULATIVE_MISC");
|
||||
|
||||
/**
|
||||
* Stand-in value for inferred urls without other context.
|
||||
*/
|
||||
final public static LinkContext INFERRED_MISC
|
||||
= new SimpleLinkContext("=INFERRED_MISC");
|
||||
|
||||
/** Stand-in value for prerequisite urls without other context. */
|
||||
final public static LinkContext PREREQ_MISC
|
||||
= new SimpleLinkContext("=PREREQ_MISC");
|
||||
|
||||
Reference in New Issue
Block a user