close

<?
$url = 'http://www.ntust.edu.tw/home.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);  
$html = curl_exec($ch);
echo $html;    
?>

短短幾行就可以撈到html , 再寫 parser 取出你想要得部分就好囉

--------------------------------------------------

如果是目標網址是 https 記得要加入

curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);

 

如果目標網址必須POST Data 則要加上

curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "Key1=Value&Key2=Value2&.........."); //再改成目標要吃的參數

 

arrow
arrow
    文章標籤
    php 爬蟲 Crawler
    全站熱搜

    天縱奇才 發表在 痞客邦 留言(0) 人氣()