Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 使用simple_html_dom&cURL,但没有获得页面的所有内容。我怎样才能得到它?_Php_Simple Html Dom - Fatal编程技术网

Php 使用simple_html_dom&cURL,但没有获得页面的所有内容。我怎样才能得到它?

Php 使用simple_html_dom&cURL,但没有获得页面的所有内容。我怎样才能得到它?,php,simple-html-dom,Php,Simple Html Dom,问题是,我得到了部分内容,但没有得到用户的评论。通过Firebug,我看到了内容,但当我检查源代码时,HTML标记内没有内容/没有相同的HTML标记。这是我的密码: <?php //Headers include('simple_html_dom.php'); function getPage($page, $redirect = 0, $cookie_file = '') { $ch = curl_init(); $headers =

问题是,我得到了部分内容,但没有得到用户的评论。通过Firebug,我看到了内容,但当我检查源代码时,HTML标记内没有内容/没有相同的HTML标记。这是我的密码:

<?php
    //Headers 
    include('simple_html_dom.php');

function getPage($page, $redirect = 0, $cookie_file = '')
{         
   $ch = curl_init();


   $headers = array("Content-type: application/json");
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
   curl_setopt($ch, CURLOPT_HEADER, 0);

   if($redirect)
   {
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);    
   }

   curl_setopt($ch, CURLOPT_URL, $page);

   if($cookie_file != '') {
     curl_setopt($ch, CURLOPT_COOKIEJAR,  $cookie_file);
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
   }

   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6');

   $return = curl_exec($ch);  //Mozilla/4.0 (compatible;)

   curl_close($ch);

   return $return;

}//EO Fn

//Source 
$url = 'http://www.vitals.com/doctor/profile/1982660171/reviews/1982660171';


//Parsing ... 
$contents = getPage($url, 1, 'cookies.txt'); 

$html = str_get_html($contents); 
//Output
echo $html->outertext;
?>

有人能帮我吗?我应该怎么做才能得到整个页面,这样我就可以抓取评论了?在这里输入代码

它们只是作为JSON存储在页面顶部的一个块中。用正则表达式或简单的HTMLDOM解析它,并运行它


但同样,请确保您有权限这样做…

我打赌这些评论是使用Ajax添加的。这个问题没有简单的解决办法——加上你可能只是在学习刮片——在这个领域也是非常新的。简单的页面我可以。你能给我写一些代码来解释如何用简单的HTML DOM或正则表达式解析这个变量json={。
var json = {"provider":{"id":"1982660171","display_name":"Stephen R Guy, MD","last_name":"Guy","first_name":"Stephen","middle_name":"Russell","master_name":"Stephen_Guy","degree_types":"MD","familiar_name":"Stephen","years_experience":"27","birth_year":"1956","birth_month":"5","birth_day":"23","gender":"M","is_limited":"false","url_deep":"http:\/\/www.vitals.com\/doctor\/profile\/1982660171\/Stephen_Guy","url_public":"http:\/\/www.vitals.com\/doctors\/Dr_Stephen_Guy.html","status_code":"A","client_ids":"1","quality_indicator_set":[{"type":"quality-indicator\/consumer-feedback","count":"2","suboverall_set":[{"name_short":"Promptness","overall":"3"},{"name_short":"Courteous Staff","overall":"4"},{"name_short":"Bedside Manner","overall":"4"},{"name_short":"Spends Time with Me","overall":"4"},{"name_short":"Follow Up","overall":"4"}],"name":"Consumer Reviews","overall":"4.0","measure_set":[{"feedback_response_id":"1756185","input_source_ids":"{0}","date":"1301544000","value":"4","scale":{"best":"1","worst":"4"},"review":{"type":"review\/consumer","comment":"I will never birth with another dr.  Granted that's not saying much as I don't like dr's but I actually find him as valuable as the midwives who I adore.  I liked Horlacher but when Kitty left I followed the midwives and then followed again....Dr. Guy is GREAT.  I honestly don't know who I'd rather support me at my birth; Margie and Lisa or Dr. Guy.  ....I wonder if I can just get all of them.Guy's great.  Know what you want.  Tell him.  Be strong and he'll support you.I give him 10 stars.  Oh...my baby's 3 years old now.  He's GREAT! ","date":"1301544000"},"sub_measure":[{"name":"Waiting time during a visit","name_short":"Promptness","value":"3","scale":{"best":"4","worst":"1"}},{"name":"Courtesy and professionalism of office staff ","name_short":"Courteous Staff","value":"4","scale":{"best":"4","worst":"1"}},{"name":"Bedside manner (caring)","name_short":"Bedside Manner","value":"4","scale":{"best":"4","worst":"1"}},{"name":"Spending enough time with me","name_short":"Spends Time with Me","value":"4","scale":{"best":"4","worst":"1"}},{"name":"Following up as needed after my visit","name_short":"Follow Up","value":"4","scale":{"best":"4","worst":"1"}}]},{"feedback_response_id":"420734","input_source_ids":"{76}","link":"http:\/\/local.yahoo.com\/info-15826842-guy-stephen-r-md-university-women-s-health-center-dayton","date":"1142398800","value":"4","scale":{"best":"1","worst":"4"},"review":{"type":"review\/consumer","comment":"Excellent Doctor: I really like going to this office. They are truely down to earth people and talk my \"non-medical\" language. I have been using thier office since 1997 and they have seen me through 2 premature pregnancies!","date":"1142398800"}}],"wait_time":"50"}]}};