duanji5569 2012-07-21 01:04
浏览 24
已采纳

从Web抓取信息

How to get informations (http://linkWeb.com, Titles, and http://link.pdf) from this html page ?

<div class="title-download">
    <div id="01divTitle" class="title">
        <h3>
            <a id="01Title" onmousedown="" href="http://linkWeb.com">Titles</a>
            <span id="01LbCitation" class="citation">(<a id="01Citation" href="http://citation.com">Citations</a>)</span></h3>
    </div>
    <div id="01downloadDiv" class="download">
        <a id="01_downloadIcon" title="http://link.pdf" onmousedown="" target=""><img id="ctl01_icon" class="small-icon";" /></a>
    </div>
</div>

I've trying but it only returns the title. I'm not aware wth simple_tml_dom before. please help me. thank you :)

<?php

include 'simple_html_dom.php';
set_time_limit(0);

$url  ='http://libra.msra.cn/Search?query=data%20mining&s=0';
$html = file_get_html($url) or die ('invalid url');
foreach($html->find('div[class=title-download]') as $webLink){
    echo $webLink->plaintext.'<br>';
    echo $webLink->href.'<br>';
}

foreach($html->find('div[class=download]') as $Link2){
    echo $webLink2->href.'<br>';    
}

?>
  • 写回答

3条回答 默认 最新

  • du8980919 2012-07-22 01:20
    关注

    Scrap the titles and urls with this code :

    foreach($html->find('span[class=citation]') as $link){
      $link = $link->prev_sibling();
      echo $link->plaintext.'<br>';
      echo $link->href.'<br>';
    }
    

    and to scrap the url in class download, using the answer given by @zigomir :)

    foreach($html->find('.download a') as $link){
       echo $link->title.'<br>';    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 单纯型python实现编译报错
  • ¥15 c++2013读写oracle
  • ¥15 c++ gmssl sm2验签demo
  • ¥15 关于模的完全剩余系(关键词-数学方法)
  • ¥15 有没有人懂这个博图程序怎么写,还要跟SFB连接,真的不会,求帮助
  • ¥15 PVE8.2.7无法成功使用a5000的vGPU,什么原因
  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音