各位前輩大家好!!
小弟剛接觸php不久還請多多包涵~
這段是view的程式碼..很簡陋
我在web_url2輸入的網址是奇摩拍賣隨便一個商品的網址
view.php
<form id="tab" action="action.php" method="post">
<input type="text" name="web_url2" id="web_url2" value="" class="form-control" />
</form>
這段則是小弟想從yahoo拍賣撈取商品價格的程式碼
action.php
include("phpQuery-onefile.php");
$web_url2 = $_POST['web_url2'];
$pq_obj_3 = phpQuery::newDocumentFileHTML("$web_url2");
$str[7] = pq('span.number',$pq_obj_3)->text();
echo "$str[7]";
而就在我執行的時候出現了這樣的錯誤
Warning: file_get_contents("Warning: file_get_contents(https://tw.bid.yahoo.com/item/%E9%9F%93%E6%AC%BE%E7%89%9B%E4%BB%94%E9%80%A3%E8%A1%A3%E8%A3%99%E5%8F%AF%E6%90%AD%E5%8E%9A%E8%B7%9F%E9%9E%8B%E6%9D%BE%E7%B3%95%E9%9E%8B%E9%AB%98%E8%B7%9F%E9%9E%8B%E5%9C%93%E9%A0%AD%E9%9E%8B%E5%8C%85%E9%9E%8B%E5%B8%86%E5%B8%83-100032472184?u=Y1416480079&actsrch=srp3) [function.file-get-contents]: failed to open stream)") [function.file-get-contents]: failed to open stream
所以想請教各位前輩...這個問題要怎麼解
感謝!!
沒有打開 openssl 的支援,所以 file_open_contents 不支援 https。
請在 php.ini 修改以下兩行
<pre class="c" name="code">; extension_dir = "ext"
改為
extension_dir = "實際有 php_openssl.dll 的目錄"
<pre class="c" name="code">;extension=php_openssl.dll
改為
extension=php_openssl.dll
即可。
在命令列視窗執行 php -m 要看到有 openssl 才是有安裝進去。
PS. 以上是假設你使用 windows 版 php。