我目前正在嘗試導航到另一個網(wǎng)頁,并使用我抓取的超鏈接獲取其 HTML。(我需要存儲在上面的信息)。我目前無法使用我生成的鏈接獲取 PHP curl 函數(shù)來獲取 HTML 代碼。我試圖用來構(gòu)建/獲取 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);}這部分之前的代碼工作正?!驗樗鼜脑季W(wǎng)頁中獲取了 HTML。如果需要,我會發(fā)布它。
1 回答

慕萊塢森
TA貢獻1810條經(jīng)驗 獲得超4個贊
您需要檢查curl_init
調(diào)用的結(jié)果。
在它之后添加echo curl_error($c) . "<br>";
以查看錯誤。很可能與 SSL 證書有關(guān)。如果是這樣,看看這個問題 - PHP - SSL certificate error: unable to get local issuer certificate
如果 curl_init 沒有錯誤,請curl_error
在每次 curl 函數(shù)調(diào)用后使用,以獲取問題說明。
- 1 回答
- 0 關(guān)注
- 136 瀏覽
添加回答
舉報
0/150
提交
取消