簡體   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