zoukankan      html  css  js  c++  java
  • 关于php抓取页面信息的简单代码

    简介:这是关于php抓取页面信息的简单代码的详细页面,介绍了和php,php, php100, contents, www 关于php抓取页面信息的简单代码有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=357331' scrolling='no'> ?利用php DOM函数实现简单的单页信息抓取   (在这里尽抓取a标签,功能实现了,但是扩展页链接抓取没有实现,欢迎大家批评指导)
    <?php
    error_reporting(E_ERROR);
    $pages = file_get_contents('http://www.php100.com');
    //$pages = htmlspecialchars($pages);
    $doc = new DOMDocument();
    $new_doc = new DOMDocument('1.0', 'utf-8');
    $doc->loadhtml($pages);
    $dom = $doc->getElementsByTagName('a');
    for ($i=0;$i<$dom->length;$i++){
    $node = $new_doc->createElement('a',$dom->item($i)->nodeValue);
    $newnode = $new_doc->appendChild($node);
    $newnode->setAttribute('href',$dom->item($i)->getAttribute('href'));
    $newnode->setAttribute('style','display:block;margin-left:30px;');//echo $dom->item($i)->getAttribute('src').'</br>';
    }
    echo $new_doc->saveHTML();
    ?>

    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/357331.html pageNo:2
  • 相关阅读:
    ovs流表机制(四)用vxlan实现多个节点的vm通信(二)
    expect
    在Scrapy中使用Selenium
    Python网络编程
    Scrapy持久化存储
    Scrapy基础
    Selenium实例
    XML和XPATH
    猫眼电影爬取
    Request模块
  • 原文地址:https://www.cnblogs.com/ooooo/p/2236041.html
Copyright © 2011-2022 走看看