簡單將自己常用的頁面抓取的函數分享給大家!
1、files();
2、file_get_contents();
3、fopen();
4、curl();
一、files()函數
二、file_get_contents()
使用file_get_contents之前必須 開啓allow_url_fopen 在php.ini 中設置allow_url_fopen= on;
三、fopen()函數
四、curl()
使用curl()必須開啓curl. php.ini 中設置extension=php_curl.dll 將前面的分號去掉哦!
!!使用curl中可能回遇到抓取空白問題
其實時忽略http和https的區別,htpps是加密的
1、將抓取的curl的https換成http
2、url_setopt參數:CURLOPT_SSL_VERIFYPEER 和 CURLOPT_SSL_VERIFYHOST 來禁用SSL證書的驗證