Loading...
Loading...
Compare original and translation side by side
chrome --headless --print-to-pdfagent-browser pdfopenawait<img>evalpdfchrome --headless --print-to-pdfopenagent-browser pdfawait<img>evalpdfagent-browser --session <unique-name> ...AGENT_BROWSER_HEADED=false~/.agent-browser/config.json"headed": true--headed false--headedexport AGENT_BROWSER_HEADED=false
agent-browser open <URL>
agent-browser wait --load networkidle
agent-browser eval "(async () => {
const sleep = ms => new Promise(r => setTimeout(r, ms));
['#onetrust-banner-sdk','#onetrust-consent-sdk','.ot-sdk-container','#ot-sdk-btn-floating','[id*=cookie]','[id*=consent]','[id*=onetrust]'].forEach(s => document.querySelectorAll(s).forEach(e => e.remove()));
document.querySelectorAll('img').forEach(img => {
img.removeAttribute('loading');
img.removeAttribute('decoding');
if (img.dataset.src) img.src = img.dataset.src;
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
});
for (let y = 0; y < document.documentElement.scrollHeight + 2000; y += 400) {
window.scrollTo(0, y);
await sleep(200);
}
window.scrollTo(0, document.documentElement.scrollHeight);
await sleep(2000);
await Promise.all(Array.from(document.images).map(i =>
i.complete && i.naturalWidth ? null
: new Promise(r => { i.addEventListener('load', r, {once:true}); i.addEventListener('error', r, {once:true}); setTimeout(r, 5000); })
));
window.scrollTo(0, 0);
await sleep(500);
return Array.from(document.images).filter(i => !i.naturalWidth).length;
})()"
agent-browser pdf /tmp/page.pdf
agent-browser closeagent-browser --session <唯一名称> ...AGENT_BROWSER_HEADED=false~/.agent-browser/config.json"headed": true--headed false--headedexport AGENT_BROWSER_HEADED=false
agent-browser open <URL>
agent-browser wait --load networkidle
agent-browser eval "(async () => {
const sleep = ms => new Promise(r => setTimeout(r, ms));
['#onetrust-banner-sdk','#onetrust-consent-sdk','.ot-sdk-container','#ot-sdk-btn-floating','[id*=cookie]','[id*=consent]','[id*=onetrust]'].forEach(s => document.querySelectorAll(s).forEach(e => e.remove()));
document.querySelectorAll('img').forEach(img => {
img.removeAttribute('loading');
img.removeAttribute('decoding');
if (img.dataset.src) img.src = img.dataset.src;
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
});
for (let y = 0; y < document.documentElement.scrollHeight + 2000; y += 400) {
window.scrollTo(0, y);
await sleep(200);
}
window.scrollTo(0, document.documentElement.scrollHeight);
await sleep(2000);
await Promise.all(Array.from(document.images).map(i =>
i.complete && i.naturalWidth ? null
: new Promise(r => { i.addEventListener('load', r, {once:true}); i.addEventListener('error', r, {once:true}); setTimeout(r, 5000); })
));
window.scrollTo(0, 0);
await sleep(500);
return Array.from(document.images).filter(i => !i.naturalWidth).length;
})()"
agent-browser pdf /tmp/page.pdf
agent-browser close
The `eval` returns the count of images that still failed to load. Expect `0`. If non-zero, the recipe didn't fully capture the page - investigate before trusting the PDF. The `pdfinfo` line is your standard end-of-recipe report (page count + bytes) so the agent has concrete numbers to relay back.
`eval`会返回仍未加载成功的图片数量,预期值为`0`。如果非零,则说明该方案未完全捕获页面——在信任该PDF之前需要进行排查。`pdfinfo`行是标准的方案结束报告(页数+字节数),以便agent可以将具体数值反馈给用户。wait --load networkidleloadingloading=lazyawait Promise.all<img>evalpdfwait --load networkidleloadingloading=lazyawait Promise.all<img>evalpdfundefinedundefined
`-dPDFSETTINGS=/ebook` keeps images legible at roughly half the raw size. `/screen` is smaller but blurrier; use only when size matters more than legibility.
`-dPDFSETTINGS=/ebook`可在保持图片清晰的前提下,将大小压缩至原始大小的约一半。`/screen`更小但更模糊;仅在大小比清晰度更重要时使用。npx percollate pdf <URL> -o out.pdf--no-hyphenate --css "@page { size: A4; margin: 18mm; } a[href]::after { content: none !important; }"agent-browser screenshot --full-pagemonolithsingle-file CLInpx percollate pdf <URL> -o out.pdf--no-hyphenate --css "@page { size: A4; margin: 18mm; } a[href]::after { content: none !important; }"agent-browser screenshot --full-pagemonolithsingle-file CLI