【问题标题】:Crawl specific information from a webpage [closed]从网页抓取特定信息[关闭]
【发布时间】:2013-07-11 18:00:26
【问题描述】:

http://www.tibia.com/community/?subtopic=characters&name=Nikla

在此链接中,人物简介的底部有一份死亡名单。 如何“收集”日期信息?我不担心其余的,只担心每次死亡的日期。

我将使用 PHP 文件来完成此操作。

我看过这个帖子:How do I make a simple crawler in PHP? 我只是不知道从哪里开始。

谁能指出我正确的方向?

【问题讨论】:

    标签: php web-crawler


    【解决方案1】:

    您可以使用像 Simple HTML DOM Parser 这样的 DOM 解析。从 SourceForge 下载存档安装它,include 脚本中的文件,然后使用它。

    该网站的表格布局很丑,但您可以这样做:

    代码:

    <?php
    
    include('simple_html_dom.php');
    $html = file_get_html('http://www.tibia.com/community/?subtopic=characters&name=Nikla');
    $count = 0; //counter variable
    foreach($html->find('//*[@id="characters"]/div[5]/div/div/table[3]/tbody/tr['.
      $i.']') as $table) { //traverse through the table and get <td> content
       echo $table."<br/>";
       $count++;
    }
    
    ?>
    

    输出:

    Character Deaths
    Jul 11 2013, 08:08:11 CEST  Killed at Level 36 by Cintyus and Seque Ladinho.
    Jul 11 2013, 07:32:31 CEST  Killed at Level 36 by Drunk Noongah and Rea Per.
    Jul 09 2013, 22:05:42 CEST  Killed at Level 35 by Evil Kris and Tensser.
    Jun 29 2013, 20:25:27 CEST  Killed at Level 27 by Knight Abron.
    Jun 27 2013, 07:31:33 CEST  Killed at Level 23 by Mysterioz Pandoria Knight.
    Jun 14 2013, 23:52:14 CEST  Died at Level 16 by a rotworm.
    

    这只是一个让您入门的示例。你可以修改它并得到你想要的。

    希望这会有所帮助!

    【讨论】:

    • 这很好,我绝对可以改变它以获得我需要的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    • 2016-08-28
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    相关资源
    最近更新 更多