简体   繁体   English

simple_html_dom.php

[英]simple_html_dom.php

I am using " simple_html_dom.php " to scrap the data from the Wikipedia site. 我正在使用“ simple_html_dom.php ”从Wikipedia网站上抓取数据。 If I run the code in scraperwiki.com it's throwing an error as exit status 139 and if run the same code in my xampp sever, the server is hanging. 如果我在scraperwiki.com中运行代码,则抛出退出状态139错误,并且如果在我的xampp服务器中运行相同的代码,则服务器正在挂起。

  1. I have a set of links 我有一组链接
  2. I'm trying to get Literacy value from all the sites 我正在尝试从所有网站上获得扫盲价值
  3. If I run the code with one link there is no problem and it's returning the expected result 如果我通过一个链接运行代码,就没有问题,它会返回预期的结果
  4. If I try to get data from all the sites in one go I'm facing the above problem 如果我尝试一次从所有站点获取数据,那么我将面临上述问题

The code is: 代码是:

<?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;
   }}}  }} 

Guide me where am wrong. 指导我哪里错了。 Is there any memory problem??? 有内存问题吗??? Is there any xampp configuration??? 是否有任何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(); 
  }
?>

but these URLs are too much. 但是这些网址太多了。 You may get a fatal error of max execution time execeeded or you may get error 324 . 您可能会收到max execution time execeededmax execution time execeeded的致命错误,或者可能会收到error 324

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

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