看板 PHP 關於我們 聯絡資訊
不好意思 我的都會出現: Fatal error: Call to undefined function: curl_init() in c:\appserv\www\051803.php on line 5 是因為php版本不同 才會沒有curl_init() 這個function嗎 謝謝 ※ 引述《wawawa (哇哇哇○( ̄﹏ ̄)○)》之銘言: : ※ 引述《destroit (翰)》之銘言: : : 各位大大 請問一下 : : 要怎麼用php抓網頁原始檔裡的資料 : : 謝謝 : 以下是簡單範例,詳細用法去看官網curl相關用法 : <?php : //抓網頁 : $url = "http://tw.dictionary.yahoo.com/search?ei=UTF-8&p=".$_POST['words']; : //雅虎的查詢網址 : $ch = curl_init(); //初始化curl,要準備開始抓網頁 : curl_setopt($ch, CURLOPT_URL, $url); //告訴url要抓的是第一行的網頁 : curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不要將抓回來的網頁秀到螢幕上, : //等等我們要繼續分析 : $content = curl_exec($ch); //抓吧,然後將資料存到$content : //開始分析,以下是用正規表示式 : preg_match('/<div class=pexplain>(.+?)<\/div>/', $content, $target); //將抓到 : //的字串存到$target : echo $target[1]; //印到螢幕上 : ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.46.5
alpe:curl_init (PHP 4 >= 4.0.2, PHP 5) 05/22 13:00
LPH66:而且好像還要有什麼設定才能用的樣子... 05/22 13:41
wawawa:要將curl模組裝進去...不行的話只好用fopen自己刻囉 05/22 14:24
chweng:拿掉php.ini中 ;extension=php_curl.dll前面的分號 05/22 16:14
chweng:存檔後重新啟動伺服器就可以了 05/22 16:14
andreli:抓原始檔用file_contents不是就可以了嗎? 05/22 22:49