simple_html_dom.php [英] simple_html_dom.php
本文介绍了simple_html_dom.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用simple_html_dom.php"从维基百科站点中抓取数据.如果我在 scraperwiki.com 中运行代码,它会抛出一个错误为 exit status 139 并且如果运行我的 xampp 服务器中的相同代码,服务器挂起.
I am using "simple_html_dom.php" to scrap the data from the Wikipedia site. 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.
- 我有一组链接
- 我正在尝试从所有网站获得扫盲价值
- 如果我用一个链接运行代码,就没有问题,它会返回预期的结果
- 如果我尝试一次性从所有站点获取数据,我将面临上述问题
代码是:
<?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配置???
Guide me where am wrong. Is there any memory problem??? Is there any xampp configuration???
推荐答案
<?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 execeeded
的致命错误,或者您可能会收到 error 324
.
but these URLs are too much. You may get a fatal error of max execution time execeeded
or you may get error 324
.
这篇关于simple_html_dom.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文