用 Claude Code 和 LMCP 將登入後儀錶板的表格匯出為 Excel
Turning a logged-in dashboard into an Excel file with Claude Code
Claude Code 配合 LMCP 可從需登入的儀錶板擷取表格並建立 Excel 檔案,登入後的工作階段可供後續執行使用,密碼不會經過 AI。表格可用 web_read 讀取頁面可見文字,或用 web_eval 直接回傳 JSON;web_extract 每個欄位只返回第一個匹配項,分頁則須逐頁操作。
Everyone has one of these: a dashboard behind a login, no export button worth using, and a weekly ritual of copying a table into Excel. This is how we'd hand that ritual to Claude Code with LMCP, a free MCP server for Mac I work on, including the parts that aren't obvious from the tool names.
Step 1: log in once
The browser tools run in LMCP's own window, not your Safari or Chrome. Ask your agent to call web_login with a session name and the URL, log in yourself (2FA included), and the session is saved for every run after that. The password never goes through the AI. (More on that in our previous post.)
Step 2: actually getting the table
This is the part people get wrong, including us at first. web_extract takes a map of field names to CSS selectors, but it returns the first match for each one. It's great for "the account balance" or "the report date", not for a table with 200 rows.
For full tables there are two good options:
-
web_readintextmode. It returns the page's visible text and the model builds the rows from it. Simple, and fine for small or medium tables. -
web_eval. It runs JavaScript in the page and returns the result as JSON, so you can ask for the table directly:
[...document.querySelectorAll('table tbody tr')]
.map(r => [...r.cells].map(c => c.innerText.trim()))
It's a power-user tool: it doesn't await async code, and it's disabled in read-only mode.
Pagination isn't automatic. If the table has pages, the agent clicks "Next" with web_click, waits with web_wait_for, and reads again. If that button submits a form, web_click asks for confirm: true first.
Step 3: writing the Excel file
excel_create takes headers and rows and writes a real .xlsx, natively, no Excel installed needed. A few behaviors worth knowing:
-
It previews before writing. The first call shows what will be created; the agent calls again with
confirm: true. -
It won't silently overwrite. If the file exists, it needs
overwrite: trueas well, and refuses otherwise. Losing last week's file by accident isn't on the menu. -
Numbers stay numbers, so
SUM()and charts work. Strings stay text even if they look numeric, and very long numbers (IDs, phone numbers) stay text too. -
One sheet, no formatting. It always creates
Sheet1, with no styling options. -
Formulas go through
excel_write_cell, one cell per call, and anything that reaches outside the file (WEBSERVICE, external links) is rejected.
If you save to Desktop, Documents or Downloads, LMCP needs Full Disk Access; without it the tool tells you how to grant it instead of quietly writing somewhere else.
Making it repeatable
LMCP has recipes: you save the sequence of tool calls once, with parameters, and run it again with recipe_run. One catch we'd rather you hear from us: a recipe step can't confirm itself. Starting a recipe that changes things takes one confirmation, but individual steps that need confirm (like excel_create) return their preview instead of running.
The pattern that works unattended is appending to a CSV with file_write, which doesn't need confirmation to create a file or add rows to one. Excel opens it fine, and you get a growing history instead of a weekly overwrite.
LMCP doesn't schedule anything itself. For "every Monday at 9", use your client's scheduled tasks or whatever already runs your jobs.
Limits, honestly
- Extraction calls time out after 10 seconds, so very heavy pages may need to be read in parts.
- "Sign in with Google" doesn't work in LMCP's browser window.
- The LMCP menu bar app has to be running for the browser tools to work.
Try it
It's free:
curl -fsSL 'https://local-mcp.com/install?ref=devto-t3' | bash
Or npx -y local-mcp@latest setup. Restart Claude Code afterwards.
What's the table you copy by hand every week?
來源:DEV Community · dev.to