我想从此 html 页面获取标题和链接:
<div class="gs_r">
<h3 class="gs_rt">
<span class="gs_ctc">[BOOK]</span>
<a href="http://example.com" onmousedown="return scife_clk(this.href,'','res','1')">titleA</a>
</h3>
<div class="gs_ggs gs_fl">
<a href="http://exampleA.pdf" onmousedown="return scife_clk(this.href,'gga','gga','1')">
我怎样才能得到它们?
这是代码:
<?php
include 'simple_html_dom.php';
$url = 'http://example.com';
$html = file_get_html($url);
//get the first link
foreach($html->find('span[class=gs_ctc]')as $Link){
echo $link;
}
foreach($html->find('div[class=gs_ggs gs_fl]')as $docLink){
echo $docLink;
}
?>