Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 嵌套在For循环问题中的Foreach循环_Php_Parsing_Loops_Simple Html Dom - Fatal编程技术网

Php 嵌套在For循环问题中的Foreach循环

Php 嵌套在For循环问题中的Foreach循环,php,parsing,loops,simple-html-dom,Php,Parsing,Loops,Simple Html Dom,我有一个脚本,可以解析一个页面中的23页并获取目录名,但是连接会重置并超时。是因为for循环中的这个嵌套foreachloop吗 <?php header('Content-type: text/html; charset=utf-8'); // this just makes sure encoding is right include('simple_html_dom.php'); // the parser library // you were trying to

我有一个脚本,可以解析一个页面中的23页并获取目录名,但是连接会重置并超时。是因为for循环中的这个嵌套foreachloop吗

<?php

header('Content-type: text/html; charset=utf-8'); // this just makes sure encoding is      right
 include('simple_html_dom.php'); // the parser library

// you were trying to parse the wrong link.. your previous link did not have <div> tag with commentText class .. I chose a random link.. choose link for whichever professor you like or grab the links of professor from previous page store it in an array and loopr through them to get comments
 $i=1;
for($i; $i < 23;$i++){
$html = file_get_html("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=834&pageNo=$i"); // the url for the teacher rating profile

 //your div tag has class "comment" not "commentText"
foreach($html->find("div[class=profName]") as $content){
 echo $content->plaintext;
 echo "<br >";  
  }
 } 


?>

我建议您使用, 它的速度相当快,可以防止你的IP被列入黑名单

与PHP一起使用它相当简单-


祝你好运

使用set_time_limit(0)循环攻击一个连续23个请求的站点很可能会使您的IP被黑。您建议我怎么做才能检索这些记录?伙计。。当我(在你上一篇文章中)通过它们写循环时,这并不意味着要攻击web链接这么多次。。只需抓取页面并循环浏览div标签即可。@Dinesh我是新手,我的意图一点也不恶意,Dinesh,我的道歉我不是故意的。什么是道德行为?