解析页面源以检索表数据,然后导出到 xls
我需要将页面的源代码转储到表单中,并让它吐出一个包含页面表内容的 xls 文件。
我想要解析的页面上有几个表,有不同的行和 11 列。每个表都有一个标题,但我不需要。我研究过使用 DOM,但我无法找到在我的应用程序中使用该对象的方法。我也考虑过使用 preg_replace() ,但同样,由于我正在处理源代码,我认为这行不通。
一旦我得到正确的解析部分,我就知道如何将其写入 php 中的 xls 文件。我只是不知道如何在 php 中解决这个问题。提前致谢。
如果有帮助的话,这就是每个表的表结构。
<table>
<thead>
<tr>
<td>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
I have a need to dump the source of a page into a form, and have it spit out an xls file containing the contents of the page's tables.
the page I wish to parse has several tables on it, of varying rows and 11 columns. Each table has a header, which I don't need. I have researched using DOM, but I couldn't figure out a way to use that object for my application. I thought about using preg_replace() as well, but again, since I am dealing with source code, I think that that wont work.
Once I get the parse portion correct, I know how to write it to a xls file in php. I just cannot figure out how to go about this in php. Thanks in advance.
If it helps, this is what the table structure looks like for each table.
<table>
<thead>
<tr>
<td>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这至少应该让你开始
This should get you started at least