通过 Chrome DevTools 浏览器自动化读取微信公众平台文章 (mp.weixin.qq.com)。当用户提供微信文章链接及其他信息时使用。
Read WeChat articles via Chrome DevTools when HTTP-based extractors fail.
google-chrome --no-first-run --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug-profiletext
navigate_page(url=<article_url>)
If the page shows "环境异常" / "去验证":
text
take_snapshot() # find the "去验证" element
click(uid=<verify_button_uid>)
If the page shows "轻触查看原文" (non-WeChat container):
text
evaluate_script(() => document.querySelector('.wx_expand_article_button_wrap')?.click())
WeChat articles use JS encryption. Content may take 3-5 seconds to decrypt after page load.
text
wait_for(text=["activity-name", "js_content"], timeout=15000)
javascript
evaluate_script(() => {
const title = document.getElementById('activity-name')?.innerText || '';
const author = document.getElementById('js_name')?.innerText || '';
const content = document.getElementById('js_content')?.innerText || '';
return { title, author, contentLength: content.length, content };
})
If activity-name is empty but js_content exists, content is loaded — just extract it.
If both are empty after 10+ seconds, try:
javascript
evaluate_script(() => new Promise(resolve => {
setTimeout(() => {
const el = document.getElementById('js_content');
resolve({ exists: !!el, htmlLen: el?.innerHTML?.length || 0, text: el?.innerText || '' });
}, 5000);
}))
Summarize or present the article content. Key fields:
SymptomCauseFix"环境异常"Captcha triggeredClick "去验证", wait for redirect"轻触查看原文"Non-WeChat browserClick the button or use JS clickEmpty content after loadJS decryption not completeWait 3-5 seconds, retry extractionChrome not connectedRemote debugging not runningStart Chrome with --remote-debugging-port=9222Page stuck on loadingNetwork or rendering issueReload page, check network conditions
evaluate_script with setTimeout (3-5s) for reliable content extraction — WeChat's JS decryption is async