module ScrapeFailureReport

Overview

Classify scrape results (url, HTTP status, body size) and report failures per host. Everything is read from the CSV; no request is made.

Defined in:

scrape_failure_report.cr

Constant Summary

CLASSES = ["ok", "empty", "redirect", "blocked", "not found", "client error", "server error", "no response", "other"]

Fixed print order. "other" holds 100 to 199, which no class above covers.

REQUIRED = ["url", "status", "bytes"] of ::String
USAGE = "usage: scrape-failure-report results.csv [--min-urls 1]\nCSV columns: url, status, bytes. Reads your own scrape log and makes no request. The minimum urls per host is set by you. More: https://www.onegtmlab.dev/tool-directory/research-and-scraping"
VERSION = "1.0.0"

Class Method Summary

Class Method Detail

def self.analyze(text : String) : Report #

Row numbers count the header as row 1.


[View source]
def self.classify(status : Int32, bytes : Int64) : String #

[View source]
def self.cli(args : Array(String), stdout : IO, stderr : IO) : Int32 #

Command line entry. Returns the exit code: 0 ok, 1 bad input or file, 2 usage.


[View source]
def self.host_of(url : String) : String | Nil #

Text between "://" and the next "/", "?" or "#", lowercased, without a leading "www.". A port is kept.


[View source]
def self.parse_csv(text : String) : Array(Array(String)) #

Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.


[View source]
def self.pct(part : Int32, whole : Int32) : String #

[View source]
def self.render(report : Report, min_urls : Int32 = 1) : String #

[View source]
def self.table(rows : Array(Array(String))) : String #

[View source]