亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從網站抓取的鏈接超鏈接獲取 HTML

從網站抓取的鏈接超鏈接獲取 HTML

PHP
素胚勾勒不出你 2022-11-04 17:10:00
我目前正在嘗試導航到另一個網頁,并使用我抓取的超鏈接獲取其 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 函數調用后使用,以獲取問題說明。


查看完整回答
反對 回復 2022-11-04
  • 1 回答
  • 0 關注
  • 144 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號