我目前正在尝试导航到另一个网页,并使用我抓取的超链接获取其 HTML。(我需要存储在上面的信息)。我目前无法使用我生成的链接获取 PHP curl 函数来获取 HTML 代码。我试图用来构建/获取 HTML 代码的代码部分是:foreach($rows as $row){    //creating the link itself. https://pr.mo.gov/ is the website itself, the attribute that is returend is the direction location.    // /pharmacy-licensee-search-detail.asp?passkey=1285356, us an example of what I get from getArrtibute('href')    $holder = "https://pr.mo.gov/".$row->getAttribute('href');    // $holder = https://pr.mo.gov/pharmacy-licensee-search-detail.asp?passkey=1285356 as per the example used in the comments above.    echo $holder;    echo "<br>";    //trying to use curl to get the website html    $c = curl_init("$holder");    $html2 = curl_exec($c);    //Trying to print out what has been recived    echo var_dump($html2);     //IT's printing out bool(false)    curl_close($c);}这部分之前的代码工作正常——因为它从原始网页中获取了 HTML。如果需要,我会发布它。
                    
                    
                1 回答
                            慕莱坞森
                            
                                
                            
                        
                        
                                                
                    TA贡献1810条经验 获得超4个赞
您需要检查curl_init调用的结果。
在它之后添加echo curl_error($c) . "<br>";以查看错误。很可能与 SSL 证书有关。如果是这样,看看这个问题 - PHP - SSL certificate error: unable to get local issuer certificate
如果 curl_init 没有错误,请curl_error在每次 curl 函数调用后使用,以获取问题说明。
- 1 回答
 - 0 关注
 - 153 浏览
 
添加回答
举报
0/150
	提交
		取消
	