code wiki / _hdl_build / nx_polite_browser.nx
nx_polite_browser.nx
buildroot/runtime/_hdl_build/nx_polite_browser.nx
about
nx_polite_browser.nx -- the first POLITE-BROWSER impersonation rung (toward Playwright-class access).
Operator: "how does playwright work to access these sites ... be POLITE like playwright and a user would."
Two first-class halves:
1. IMPERSONATE -- emit the REAL Chrome request header set (User-Agent + sec-ch-ua + Accept ordering) so a
header-fingerprinting WAF serves us as a browser (the cheapest bot-detection rung; TLS-JA3 + a JS engine
are the deeper follow-on rungs).
2. POLITE -- respect robots.txt (Disallow prefix under User-agent: *), honor Crawl-delay, rate-limit per host.
A courteous USER, not an abusive scraper -- we DENY ourselves disallowed paths before fetching.
Produces the headers + the politeness verdict; the transport (nx_h2_client_over_tls / nx_crawl_https) consumes
them. BAKED GATE proves the robots allow/deny + crawl-delay parse.
module: nishi-core.web.polite_browser
depends: nishi-core.sys.syscalls
capability: POLITE_BROWSER_IMPERSONATION_AND_ROBOTS
license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_codec_caps.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 18 | const PB_MAGIC_1024: i64 = 1024 |
| 20 | const PB_LOG: *u8 = "knowledge/status/polite_browser.log" |
functions
| 22 | func pb_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 23 | func pb_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 24 | func pb_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: pb_robots_allowed |
| 25 | func pb_cpy(dst: *u8, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[i]=s[i]; i=i+1} dst[i]=0 as u8; return i } called by 1: main |
| 28 | func pb_emit_headers(fd: i64) -> i64 |
| 52 | func pb_skip_sp(buf: *u8, p: i64, le: i64) -> i64 { var q: i64=p; while q<le { if buf[q]==(32 as u8){q=q+1} else { return q } } return le } |
| 54 | func pb_at(buf: *u8, le: i64, i: i64, pat: *u8, pl: i64) -> i64 |
| 59 | func pb_has_star(buf: *u8, s: i64, le: i64) -> i64 { var p: i64=s; while p<le { if buf[p]==(42 as u8){return 1} p=p+1 } return 1 } called by 1: pb_robots_allowed |
| 61 | func pb_prefix(path: *u8, pl: i64, buf: *u8, ds: i64, de: i64) -> i64 called by 1: pb_robots_allowed |
| 67 | func pb_robots_allowed(buf: *u8, n: i64, path: *u8) -> i64 |
| 95 | func pb_crawl_delay(buf: *u8, n: i64) -> i64 |
| 118 | func main() -> i64 |