{
  "schemaVersion": 1,
  "slug": "scrapling-first-run",
  "tool": {
    "name": "Scrapling",
    "repo": "D4Vinci/Scrapling",
    "version": "0.5.1"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.4 LTS",
    "runtime": "Python 3.12.3",
    "installSeconds": 6.7,
    "installBytes": 31620373
  },
  "method": {
    "hypothesis": "README 사용법: 패키지를 설치한 뒤 Fetcher 또는 StealthyFetcher로 웹 문서를 가져와 CSS와 XPath 선택자로 텍스트 및 링크 목록을 추출한다. 이 환경에서 확인: 기본 패키지 단독 설치 후 임포트와 문서 조회 및 정적 HTML 대상 CSS·XPath 추출이 오프라인에서 동작하는지 확인하고 네트워크와 브라우저가 없는 상태에서 Fetcher 및 StealthyFetcher 호출이 내는 예외 종류를 기록한다.",
    "conditions": [
      "외부 네트워크와 브라우저 실행 파일 없이 기본 패키지만 설치된 오프라인 격리 환경에서 원격 요청을 각 한 번 호출한다",
      "결정적 정적 HTML 문서 1페이지 안에 인용 블록 50개와 본문 링크 20개를 넣어 CSS와 XPath 선택자로 총 120항목을 추출한다",
      "성공 여부 지표가 1이면 해당 단계가 정상 완료된 것이고 0이면 실패한 것이며 원격 호출 실패 원인은 오류 종류 문자열로 판독한다"
    ],
    "repeats": 5
  },
  "script": "import gc\nimport importlib\nimport importlib.metadata\nimport json\nimport pydoc\nimport signal\nimport sys\nfrom time import perf_counter\n\n\ndef err_kind(exc: BaseException) -> str:\n    cls = type(exc)\n    mod = getattr(cls, '__module__', '') or ''\n    name = cls.__name__\n    if mod and mod not in ('builtins', '__main__'):\n        return f'{mod}.{name}'\n    return name\n\n\ndef _on_alarm(signum, frame):\n    raise TimeoutError('sandbox call timed out')\n\n\nif hasattr(signal, 'SIGALRM'):\n    signal.signal(signal.SIGALRM, _on_alarm)\n\nt0 = perf_counter()\nimport_ok = 0\ntry:\n    importlib.import_module('scrapling')\n    import_ok = 1\nexcept (Exception, SystemExit):\n    import_ok = 0\nimport_ms = round((perf_counter() - t0) * 1000.0, 3)\n\nt0 = perf_counter()\nhelp_ok = 0\nhelp_bytes = 0\nSelector = None\ntry:\n    ver = importlib.metadata.version('scrapling')\n    try:\n        from scrapling.parser import Selector as _Selector\n    except ImportError:\n        from scrapling import Selector as _Selector\n    Selector = _Selector\n    doc_text = f'scrapling=={ver}\\n' + pydoc.plain(pydoc.render_doc(Selector))\n    help_bytes = len(doc_text.encode('utf-8'))\n    if ver and help_bytes > 0:\n        help_ok = 1\nexcept (Exception, SystemExit):\n    help_ok = 0\nhelp_ms = round((perf_counter() - t0) * 1000.0, 3)\n\nquote_blocks = ''.join(\n    f'<div class=\"quote\"><span class=\"text\">Quote {i}</span><small class=\"author\">Author {i}</small></div>'\n    for i in range(50)\n)\nlink_blocks = ''.join(\n    f'<a href=\"https://example.com/item/{j}\">Item {j}</a>'\n    for j in range(20)\n)\nhtml_fixture = (\n    '<!doctype html><html><head><meta charset=\"utf-8\"><title>Scrapling</title></head>'\n    f'<body><main>{quote_blocks}</main><section id=\"padded_content\">{link_blocks}</section></body></html>'\n)\n\nt0 = perf_counter()\nparse_ok = 0\nparse_bytes = 0\nparse_items = 0\nif Selector is not None:\n    try:\n        page = Selector(html_fixture)\n        css_quotes = page.css('.quote .text::text').getall()\n        css_links = page.css('#padded_content a').getall()\n        xpath_quotes = page.xpath('//span[@class=\"text\"]/text()').getall()\n        extracted = [*css_quotes, *css_links, *xpath_quotes]\n        parse_items = len(extracted)\n        parse_bytes = sum(len(f'{item}'.encode('utf-8')) for item in extracted)\n        if (\n            len(css_quotes) == 50\n            and len(css_links) == 20\n            and len(xpath_quotes) == 50\n            and f'{css_quotes[0]}' == 'Quote 0'\n            and f'{xpath_quotes[49]}' == 'Quote 49'\n        ):\n            parse_ok = 1\n    except (Exception, SystemExit):\n        parse_ok = 0\nparse_ms = round((perf_counter() - t0) * 1000.0, 3)\n\nt0 = perf_counter()\nfetcher_ok = 0\nfetcher_bytes = 0\nfetcher_err = 'none'\nif hasattr(signal, 'SIGALRM'):\n    signal.alarm(12)\ntry:\n    from scrapling.fetchers import Fetcher\n    resp = Fetcher.get('https://example.com')\n    _ = resp.css('.quote .text::text').getall()\n    body = getattr(resp, 'body', b'') or b''\n    fetcher_bytes = len(body) if isinstance(body, (bytes, bytearray)) else len(f'{body}'.encode('utf-8'))\n    fetcher_ok = 1\n    resp = None\nexcept (Exception, SystemExit) as exc:\n    fetcher_err = err_kind(exc)\nfinally:\n    if hasattr(signal, 'SIGALRM'):\n        signal.alarm(0)\nfetcher_ms = round((perf_counter() - t0) * 1000.0, 3)\n\nt0 = perf_counter()\nstealthy_ok = 0\nstealthy_bytes = 0\nstealthy_err = 'none'\nif hasattr(signal, 'SIGALRM'):\n    signal.alarm(12)\ntry:\n    from scrapling.fetchers import StealthyFetcher\n    resp = StealthyFetcher.fetch('https://example.com', solve_cloudflare=True)\n    _ = resp.css('#padded_content a').getall()\n    body = getattr(resp, 'body', b'') or b''\n    stealthy_bytes = len(body) if isinstance(body, (bytes, bytearray)) else len(f'{body}'.encode('utf-8'))\n    stealthy_ok = 1\n    resp = None\nexcept (Exception, SystemExit) as exc:\n    stealthy_err = err_kind(exc)\nfinally:\n    if hasattr(signal, 'SIGALRM'):\n        signal.alarm(0)\nstealthy_ms = round((perf_counter() - t0) * 1000.0, 3)\n\nresult = {\n    'importMs': import_ms,\n    'importOk': import_ok,\n    'helpMs': help_ms,\n    'helpBytes': help_bytes,\n    'helpOk': help_ok,\n    'parseMs': parse_ms,\n    'parseBytes': parse_bytes,\n    'parseItems': parse_items,\n    'parseOk': parse_ok,\n    'fetcherMs': fetcher_ms,\n    'fetcherBytes': fetcher_bytes,\n    'fetcherOk': fetcher_ok,\n    'fetcherErr': fetcher_err,\n    'stealthyMs': stealthy_ms,\n    'stealthyBytes': stealthy_bytes,\n    'stealthyOk': stealthy_ok,\n    'stealthyErr': stealthy_err,\n}\ngc.collect()\nsys.stdout.write(json.dumps(result, ensure_ascii=True) + '\\n')\nsys.stdout.flush()\n",
  "scriptSha256": "3716287b4cf696c1832603a36b3988fc5223c294b0138c57142ecf8b56875042",
  "runs": [
    {
      "run": 1,
      "importMs": 0.232,
      "importOk": 1,
      "helpMs": 77.3,
      "helpBytes": 17846,
      "helpOk": 1,
      "parseMs": 2.372,
      "parseBytes": 1740,
      "parseItems": 120,
      "parseOk": 1,
      "fetcherMs": 1.573,
      "fetcherBytes": 0,
      "fetcherOk": 0,
      "fetcherErr": "ModuleNotFoundError",
      "stealthyMs": 0.301,
      "stealthyBytes": 0,
      "stealthyOk": 0,
      "stealthyErr": "ModuleNotFoundError",
      "wallMs": 266.058
    },
    {
      "run": 2,
      "importMs": 0.196,
      "importOk": 1,
      "helpMs": 65.181,
      "helpBytes": 17846,
      "helpOk": 1,
      "parseMs": 1.343,
      "parseBytes": 1740,
      "parseItems": 120,
      "parseOk": 1,
      "fetcherMs": 1.409,
      "fetcherBytes": 0,
      "fetcherOk": 0,
      "fetcherErr": "ModuleNotFoundError",
      "stealthyMs": 0.337,
      "stealthyBytes": 0,
      "stealthyOk": 0,
      "stealthyErr": "ModuleNotFoundError",
      "wallMs": 265.176
    },
    {
      "run": 3,
      "importMs": 0.196,
      "importOk": 1,
      "helpMs": 65.43,
      "helpBytes": 17846,
      "helpOk": 1,
      "parseMs": 1.325,
      "parseBytes": 1740,
      "parseItems": 120,
      "parseOk": 1,
      "fetcherMs": 1.405,
      "fetcherBytes": 0,
      "fetcherOk": 0,
      "fetcherErr": "ModuleNotFoundError",
      "stealthyMs": 0.323,
      "stealthyBytes": 0,
      "stealthyOk": 0,
      "stealthyErr": "ModuleNotFoundError",
      "wallMs": 265.772
    },
    {
      "run": 4,
      "importMs": 0.204,
      "importOk": 1,
      "helpMs": 64.448,
      "helpBytes": 17846,
      "helpOk": 1,
      "parseMs": 1.3,
      "parseBytes": 1740,
      "parseItems": 120,
      "parseOk": 1,
      "fetcherMs": 1.384,
      "fetcherBytes": 0,
      "fetcherOk": 0,
      "fetcherErr": "ModuleNotFoundError",
      "stealthyMs": 0.344,
      "stealthyBytes": 0,
      "stealthyOk": 0,
      "stealthyErr": "ModuleNotFoundError",
      "wallMs": 265.567
    },
    {
      "run": 5,
      "importMs": 0.191,
      "importOk": 1,
      "helpMs": 65.219,
      "helpBytes": 17846,
      "helpOk": 1,
      "parseMs": 1.352,
      "parseBytes": 1740,
      "parseItems": 120,
      "parseOk": 1,
      "fetcherMs": 1.335,
      "fetcherBytes": 0,
      "fetcherOk": 0,
      "fetcherErr": "ModuleNotFoundError",
      "stealthyMs": 0.337,
      "stealthyBytes": 0,
      "stealthyOk": 0,
      "stealthyErr": "ModuleNotFoundError",
      "wallMs": 266.131
    }
  ],
  "summary": {
    "importMs": {
      "median": 0.196,
      "min": 0.191,
      "max": 0.232,
      "unit": "ms"
    },
    "importOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "helpMs": {
      "median": 65.219,
      "min": 64.448,
      "max": 77.3,
      "unit": "ms"
    },
    "helpBytes": {
      "median": 17846,
      "min": 17846,
      "max": 17846,
      "unit": "bytes"
    },
    "helpOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "parseMs": {
      "median": 1.343,
      "min": 1.3,
      "max": 2.372,
      "unit": "ms"
    },
    "parseBytes": {
      "median": 1740,
      "min": 1740,
      "max": 1740,
      "unit": "bytes"
    },
    "parseItems": {
      "median": 120,
      "min": 120,
      "max": 120,
      "unit": "items"
    },
    "parseOk": {
      "median": 1,
      "min": 1,
      "max": 1,
      "unit": "flag"
    },
    "fetcherMs": {
      "median": 1.405,
      "min": 1.335,
      "max": 1.573,
      "unit": "ms"
    },
    "fetcherBytes": {
      "median": 0,
      "min": 0,
      "max": 0,
      "unit": "bytes"
    },
    "fetcherOk": {
      "median": 0,
      "min": 0,
      "max": 0,
      "unit": "flag"
    },
    "stealthyMs": {
      "median": 0.337,
      "min": 0.301,
      "max": 0.344,
      "unit": "ms"
    },
    "stealthyBytes": {
      "median": 0,
      "min": 0,
      "max": 0,
      "unit": "bytes"
    },
    "stealthyOk": {
      "median": 0,
      "min": 0,
      "max": 0,
      "unit": "flag"
    }
  },
  "createdAt": "2026-11-08T17:11:10Z"
}
