解析php通過cookies獲取遠(yuǎn)程網(wǎng)頁的指定代碼
更新時(shí)間:2013年06月25日 17:20:36 作者:
本篇文章是對php通過cookies獲取遠(yuǎn)程網(wǎng)頁的指定代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
復(fù)制代碼 代碼如下:
function Steal($url, $post_data = ""){
//$header[] = "Accept: text/vnd.wap.wml,*.*";
$user_agent = "Mozilla/4.0";
$follow_loc = 1;
$cookie_file ="./tmp/cook.txt";
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_URL, $url);
@curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
@curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
@curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
@curl_setopt($ch, CURLOPT_HEADER, $header);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow_loc);
@curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
if (trim($post_data)!= "") {
@curl_setopt($ch, CURLOPT_POST, 1);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$result = @curl_exec($ch);
@curl_close($ch);
return $result;
}
//獲取網(wǎng)頁代碼的方法
function Cut($file,$from,$end){
$message=explode($from,$file);
$message=explode($end,$message[1]);
if ($message[0] == "")
{
$message[0] = "<font color= '#ff0000'>無法獲取內(nèi)容</font>";
}
return $message[0];
}
//截取代碼的方法
相關(guān)文章
php獲取網(wǎng)頁里所有圖片并存入數(shù)組的方法
這篇文章主要介紹了php獲取網(wǎng)頁里所有圖片并存入數(shù)組的方法,涉及php正則匹配及數(shù)組操作的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04PHP-FPM運(yùn)行狀態(tài)的實(shí)時(shí)查看及監(jiān)控詳解
php-fpm和nginx一樣內(nèi)建了一個(gè)狀態(tài)頁,對于想了解php-fpm的狀態(tài)以及監(jiān)控php-fpm非常有幫助。這篇文章就給大家詳細(xì)介紹了PHP-FPM運(yùn)行狀態(tài)的實(shí)時(shí)查看及監(jiān)控,有需要的朋友們可以參考學(xué)習(xí),感興趣的朋友們下面來一起看看吧。2016-11-11php 輸出緩沖 Output Control用法實(shí)例詳解
這篇文章主要介紹了php 輸出緩沖 Output Control用法,結(jié)合實(shí)例形式詳細(xì)分析了php 輸出緩沖 Output Control基本概念、原理、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2020-03-03