Skip to content

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.

fs_overwrite(filename, content)
async
Param Type Description
filename string File name (relative to job directory)
content string New file content

None.

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_result
end