听起来很简单,但我是新的整个屏幕报废的东西。我已经是一个远程站点http://www.remotesite.com(例如目的),有计划表,象这样的结构:屏幕抓取PHP的两列表
<table>
<tr>
<td class="team">
Team 1
</td>
<td class="team">
Team 2
</td>
</tr>
</table>
表中填充取决于游戏持续了数项的动态范围第一队和第二队等。
我已经构建了我的报废队伍,以获得表中列出的所有队伍的列表,并且它可以成功运行。下面的代码:
<?php
// Load Simple DOM
include_once("simple_html_dom.php");
// Scrape the Schedule
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$html = file_get_html("http://www.remotesite.com/schedule.htm");
// Load HTML
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
// Get all the Teams
$my_xpath_query = "//table//td[contains(@class, 'team')]";
$result_rows = $xpath->query($my_xpath_query);
>
而且呼应刮我有这样的代码:
<?php
// Display the schedule
foreach ($result_rows as $result_object){
echo $result_object->nodeValue;
}
?>
然而,这样做是呼应了像这样的球队:
Team1Team2Team3Team4Team5Team6 etc, etc.
它正在获得正确的顺序相互对抗的球队对,但我需要做的是es基本上以我提取它的相同方式回显表格。
在此先感谢您提供的任何帮助!
是什么_“什么,我需要做的是基本呼应出表,我取了同样的方式它的意思是? – Madbreaks
我想要完整地获取表格并将其从我的脚本中回显到屏幕上。 – rws907
为什么要搜索'// table // td ...'呢?为什么不只是表本身的XPath查询? – Madbreaks