Two problems in the HTTP targets.
First, HTTPTarget and HTTPXAPITarget save str(response.content) when there's no callback. content is bytes, so what ends up in memory is the Python repr: b'...' with every non-ASCII character escaped. The regex callback searches that same repr, so matches pick up escapes and a trailing quote:
server text: 'Sure — here’s the answer:\nStep 1: café'
stored: "b'Sure \\xe2\\x80\\x94 here\\xe2\\x80\\x99s the answer:\\nStep 1: caf\\xc3\\xa9'"
regex 'Step 1: .*': "Step 1: caf\\xc3\\xa9'"
You can see it in the saved output of doc/code/targets/10_http_target.ipynb too (b'<!DOCTYPE html>...).
Second, _fetch_key tokenizes with ([a-zA-Z_]+), so keys with digits or hyphens get split. output2 looks up output, generated-text looks up generated, and both raise.
Fix: use response.text, and treat anything other than ., [ and ] as part of a key.
Two problems in the HTTP targets.
First,
HTTPTargetandHTTPXAPITargetsavestr(response.content)when there's no callback.contentis bytes, so what ends up in memory is the Python repr:b'...'with every non-ASCII character escaped. The regex callback searches that same repr, so matches pick up escapes and a trailing quote:You can see it in the saved output of
doc/code/targets/10_http_target.ipynbtoo (b'<!DOCTYPE html>...).Second,
_fetch_keytokenizes with([a-zA-Z_]+), so keys with digits or hyphens get split.output2looks upoutput,generated-textlooks upgenerated, and both raise.Fix: use
response.text, and treat anything other than.,[and]as part of a key.