解析HTML表-PHP [英] Parse HTML Table - PHP
问题描述
我有一个要在PHP中解析的HTML表,以存储到MySQL数据库中. HTML看起来像这样:
I have an HTML table that I would like to parse in PHP to store into a MySQL Database. The HTML looks like this:
<tr><td>DATE</td><td>LOCATION</td><td><a href="URL">NAME</a></td></tr>
我想创建一个PHP函数,该函数以数组形式返回,字段以大写字母表示.有谁知道任何可以执行此操作的PHP库,或者我应该使用其他语言,因为这可能很复杂.我不知道该如何使用页面上的许多表格来执行此操作,但是我正在尝试解析机器人事件.我要解析的表从第465行开始.
I would like to create a PHP function that returns in an array, the fields in capital letters. Does anyone know any php libraries that can do this, or should I be using a different language, as this may be complex. I don't know exactly how to do this with many tables on the page, but I am trying to parse the VEX events on RobotEvents. The table that I want to parse starts at line 465.
推荐答案
当您准备超越PHP时,请 Nokogiri (Ruby)和 Beautiful Soup (Python)是建立良好的库,可以很好地解析HTML .
As you're prepared to look beyond PHP, Nokogiri (Ruby) and Beautiful Soup (Python) are well-established libraries that parse HTML very well.
这并不意味着没有合适的PHP库.
That doesn't imply that there are no suitable PHP libraries.
这篇关于解析HTML表-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!