繁体   English   中英

simple_html_dom.php

[英]simple_html_dom.php

我正在使用“ simple_html_dom.php ”从Wikipedia网站上抓取数据。 如果我在scraperwiki.com中运行代码,则抛出退出状态139错误,并且如果在我的xampp服务器中运行相同的代码,则服务器正在挂起。

  1. 我有一组链接
  2. 我正在尝试从所有网站上获得扫盲价值
  3. 如果我通过一个链接运行代码,就没有问题,它会返回预期的结果
  4. 如果我尝试一次从所有站点获取数据,那么我将面临上述问题

代码是:

<?php 
  $test=array
  ( 
   0 => "http://en.wikipedia.org/wiki/Andhra_Pradesh",
   1 => "http://en.wikipedia.org/wiki/Arunachal_Pradesh",
   2 => "http://en.wikipedia.org/wiki/Assam",
   3 => "http://en.wikipedia.org/wiki/Bihar",
   4 => "http://en.wikipedia.org/wiki/Chhattisgarh",
   5 => "http://en.wikipedia.org/wiki/Goa",

   for($ix=0;$ix<=9;$ix++){

     $content = file_get_html($test[$ix]);
     $tables = $content ->find('#mw-content-text table',0);
     foreach ($tables ->children() as $child1) {
        foreach($child1->find('th a') as $ele){
        if($ele->innertext=="Literacy"){
                foreach($child1->find('td') as $ele1){
                   echo $ele1->innertext;
   }}}  }} 

指导我哪里错了。 有内存问题吗??? 是否有任何xampp配置???

<?php 
  require 'simple_html_dom.php';
  $test = array( 
   0 => "http://en.wikipedia.org/wiki/Andhra_Pradesh",
   1 => "http://en.wikipedia.org/wiki/Arunachal_Pradesh",
   2 => "http://en.wikipedia.org/wiki/Assam",
   3 => "http://en.wikipedia.org/wiki/Bihar",
   4 => "http://en.wikipedia.org/wiki/Chhattisgarh",
   5 => "http://en.wikipedia.org/wiki/Goa");

  for($ix=0;$ix<=count($test);$ix++){
    $content = file_get_html($test[$ix]);
    $tables = $content ->find('#mw-content-text table',0);
    foreach ($tables ->children() as $child1) {
      foreach($child1->find('th a') as $ele){
        if($ele->innertext=="Literacy"){
          foreach($child1->find('td') as $ele1){
            echo $ele1->innertext;
          }
        }
      }
    }   
    $content->clear(); 
  }
?>

但是这些网址太多了。 您可能会收到max execution time execeededmax execution time execeeded的致命错误,或者可能会收到error 324

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM