如何从表链接,并将其与PHP保存在file.txt的:获取从表PHP链接
<TABLE width="600" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<TR>
<TD width="15"></TD>
<TD width="570" valign="top">
<TABLE width="570" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<TR>
<TD width="190" valign="top">
<TABLE width="190" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<TR height="98">
<TD width="190" align="center" valign="top"><A HREF="http://mylink.com/1" class="opacityit"><IMG SRC="http://mylink.com/1/784.jpg" title="test1" title="test1" BORDER=0 style="cursor:hand" /></A></TD>
</TR>
<TR height="2">
<TD width="190"></TD>
</TR>
<TR>
<TD width="190" align="center" Class="text6"><A HREF="http://mylink.com/1" class="Link8" title="test1"><h2 style="color:#000"><font size=2>test1</font></h2></A></TD>
</TR>
</TABLE>
</TD>
<TABLE width="190" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<TR height="98">
<TD width="190" align="center" valign="top"><A HREF="http://mylink.com/2" class="opacityit"><IMG SRC="http://mylink.com/2/784.jpg" title="test2" title="test2" BORDER=0 style="cursor:hand" /></A></TD>
</TR>
<TR height="2">
<TD width="190"></TD>
</TR>
<TR>
<TD width="190" align="center" Class="text6"><A HREF="http://mylink.com/2" class="Link8" title="test2"><h2 style="color:#000"><font size=2>test2</font></h2></A></TD>
</TR>
</TABLE>
</TD>
$ HTML =的file_get_contents($ urlcontent );
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//tr");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
如何从表链接,并将其与PHP保存在file.txt的
我只是想表
http://mattgemmell.com/what-have-you-tried/ – Umair 2015-01-21 11:20:30
有这样做的几种方法。至少告诉我们你卡在哪里。 – TNC 2015-01-21 11:21:29
我无法检索链接代码不工作? – 2015-01-21 11:29:40