fs_overwrite
fs_overwrite(filename, content) replaces the entire content of a file in the job’s directory. Ideal for keeping a “latest” snapshot of your scraping results.
Signature
Section titled “Signature”fs_overwrite(filename, content)
asyncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
filename |
string | File name (relative to job directory) |
content |
string | New file content |
Returns
Section titled “Returns”None.
Example
Section titled “Example”function after_fetch(fetch_result, ctx) if fetch_result.response then local etag = fetch_result.response.headers["ETag"] if etag then fs_overwrite("last_response.json", json_encode({ etag = etag })) end end return fetch_resultend