【发布时间】:2015-12-04 05:58:30
【问题描述】:
我正在抓取网页中的值并将它们存储在一个数组中,目前我可以提取所有 td.Place 值,因为它有一个类。
注意:我使用的是简单的 HTML DOM Parser
我当前有效的代码:
<?php
include('simple_html_dom.php');
$html = file_get_html('http://www...');
// initialize empty array to store the data array from each row
$theData3 = array();
// initialize array to store the cell data from each row
$rowData3 = arra
foreach($row->find('td.Place') as $cell)
{
// push the cell's text to the array
$rowData3[] = $cell->innertext;
}
// push the row's data array to the 'big' array
$theData3[] = $rowData3;
}
print_r($theData3);
?>
有什么问题?
我想在 class="Grad 中提取值 100 和 - 3。** 1234562 内的前两个 td= “研究生*。因为这两个 TD 值没有 id 或 class 我觉得很难。
这是我目前正在抓取的 html
<tr class="PersonrRow odd">
<td></td>
<td class="place">T9</td>
<td>
<span class="rank"></span>16</td>
<td class="Grad">-7
</td>
<td>
100
</td>
<td>
-3
</td>
<td>
712
</td>
<td>
682
</td>
<td>
702
</td>
<td>
68
</td>
<td class="person large"></td>
<td style="">
277
</td>
</tr>
【问题讨论】:
-
我很困惑你是使用 php 来废弃这个还是 jquery,因为我在这个问题中看不到 jquery 的知识
-
道歉马克我正在使用 php,我将从我的问题的标签中删除 jquery。谢谢
-
这里的问题看不懂,说清楚点
-
你也可以把你的完整代码放在这里。我之前已经构建了一个爬虫,如果我能看到你的完整代码,我将能够快速帮助你。
-
感谢 Mark 我添加了更多代码。