离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
HTML 表格转 CSV——离线、可批量、不上传HTML table to CSV offline, in batches, no upload
网页存下来的是 HTML,想拿数据还得自己刮。这条链路只认文档里的 `<table>`:首行给出列名,其余每行一条记录,按值写成 CSV。取行取格都用「只看这张表自己」的作用域去读,所以内层表格的行不会被当成外层的数据行,表头用 `<th>` 写的文档也不会因为只读 `<td>` 而整列左移。链接取文字、表格外的脚本与样式变不成行,而页面里指向网络的图片与字体一概不会被请求——扩展本身也只有 storage 权限。A saved page is HTML, and the data inside it still has to be scraped. This route reads only the `<table>` elements: the first row supplies column names, each other row becomes a record, and the CSV is written from values. Rows and cells are read with a “this table only” scope, so a table nested inside a cell does not have its rows mistaken for the outer table’s data, and a document whose header row is written with `th` does not shift a whole column left. Links contribute their text, scripts and styles outside the tables never become a row, and nothing a page points at on the network is ever requested — the extension itself carries only the storage permission.
这条链路怎么走How the route runs
HTMLHTML JSONJSON CSVCSV
共 2 步,由扩展的路径搜索自动选出,中间产物不落盘。2 steps, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 首行当列名、其余行当记录;`<th>` 和 `<td>` 都算一格,所以用 `<th>` 写表头的文档不会整列左移The first row supplies column names and the rest are records, with both `th` and `td` counting as cells, so a header written as `th` cannot shift the row one column left
- 只取这张表自己的行与格:内层的行不会被摊平成外层的数据行(但内层那张表本身也算一张表,见下面的限制)Only the table’s own rows and cells are taken, so an inner table’s rows are never flattened into the outer table’s data — though that inner table still counts as a second table, which the limits below come back to
- 按值写出、不走显示格式:格子本来就是页面里的文本;文件开头带 UTF-8 BOM,实测 `2024-01-05` 与 `1727000000000` 都原样落地Written from values rather than display text — the cells are the page’s own text — and the file starts with a UTF-8 BOM: measured, `2024-01-05` and `1727000000000` arrive exactly as written
- 没有 `<table>` 时会退一步读 `<pre>` / `<code>` 里的 JSON,能解析成数组就有 CSV;解析不了直接报错,不给空文件With no `<table>` at all, a JSON array inside `<pre>` / `<code>` is read instead; anything unparseable is reported rather than an empty file
如实说明的限制What it does not do
- 一次只认一张表:页面里有两张以上(**表格套在单元格里也算两张**)时,中间那一步会把它们并成一个按文档里小标题顺序分组的对象(标题不够就用 `Sheet2` 这类名字),而 CSV 只接受数组,于是整次转换报错。要逐张拿,先各存成一份只含一张表的 HTMLOne table at a time: with two or more — and a table nested inside a cell counts as a second one — the middle step merges them into one object keyed by the document’s headings in order, falling back to names like `Sheet2` when there are not enough, and CSV accepts only arrays, so the whole conversion fails. Save one table per file to take them separately
- 列数由首行决定:某行比表头多的单元格会被丢掉,少的列写空;首行里重复或为空的表头会互相覆盖,跨 `colspan` 的表头只算一格The first row defines the columns: a row with more cells than the header has the extras dropped and a row with fewer gets empty columns, a repeated or empty header overwrites its twin, and a header spanning `colspan` counts once
- 链接只剩文字,`href` 不进 CSV;表单控件与图片没有文字可贡献,脚本与样式也变不成行A link contributes its text, so the `href` is not in the CSV, form controls and images have no text to contribute, and scripts and styles never become a row
- 以 `=`、`+`、`-`、`@` 开头的文本会被加一个前导单引号,防止这份 CSV 再被 Excel 当公式执行——所以它不是逐字节原样Text starting with `=`, `+`, `-` or `@` is prefixed with an apostrophe so the CSV cannot be re-evaluated as a formula, which means it is not a byte-for-byte copy
- 读文档用的是宽松解码:脏字节不会变成正文,但也没有「编码猜错就报错」这道闸,编码很怪的旧文件请自己先确认The document is read with a lenient decoder: stray bytes do not become text, but there is no “fail if the encoding cannot be guessed” gate, so confirm a badly mangled old file yourself
实操提示Working with it
- 一批最多 200 个文件,单个文件上限 100 MB;多个 .html 一起转逐个产出各自的 .csv,想一次拿走就打成一个 ZIPUp to 200 files per batch and 100 MB per file; several .html files yield one .csv each, and the set can be taken as a single ZIP
- 要的是 JSON 对象而不是 CSV,走 HTML 转 JSON——那条能吃多张表(按 `<h2>` 分组成一个对象)For JSON objects rather than CSV rows, take HTML to JSON — that route does accept several tables, grouping them under their `<h2>` headings
- 要的是能再算的工作表而不是纯文本,走 HTML 转 Excel——但那是同一条链的延伸(HTML → JSON → CSV → Excel),所以「多张表」在那里同样被拒绝,只在页面只含一张表时好用For a workbook you can keep computing in, take HTML to Excel — but that is the same chain extended (HTML → JSON → CSV → Excel), so several tables are refused there too and it works when the page holds one table
常见问题Questions people actually ask
页面里有多张表,能一次都转成 CSV 吗?The page has several tables — can they all become one CSV?
不能。多张表在 HTML 转 JSON 那一步会并成一个按文档小标题顺序分组的对象,而 JSON 转 CSV 只接受数组,所以会明确报错。想全拿就分别存成只含一张表的 HTML,或者改走 HTML 转 JSON(那条能吃多张表)。No. Several tables are merged by the HTML-to-JSON step into an object keyed by the document’s headings in order, and JSON-to-CSV accepts only arrays, so it fails with a clear message. Save one table per file, or take HTML to JSON instead — that route does accept several tables.
表格里的链接地址会丢吗?Are the link addresses inside the table lost?
是,只留链接文字。要地址就先走 HTML 转 JSON(同样只取文字,但结构更完整)或直接编辑源文件。这条路的定位是「把看得见的表格变成能算的数据」,不是抓取。Yes — only the link’s text comes through. If you need addresses, go HTML to JSON first, or edit the source. This route is “make the visible table computable”, not a scraper.
打开这份 HTML 时会自动去请求页面里引用的图片和样式吗?Does opening that HTML fetch the images and stylesheets it references?
不会。扩展完全离线,只有 storage 权限、没有 host 权限,浏览器也拦得住;转换读的是文件自己的字节。No. The extension is fully offline — the storage permission only, no host permissions, and the browser would block it anyway. The conversion reads the file’s own bytes.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub