當前位置:首頁 » 編程語言 » snoopyphp登錄

snoopyphp登錄

發布時間: 2023-06-03 13:27:57

1. 請問php模擬登錄後怎麼保持session總是不能成功保持session到目標站的其他頁面

請問樓主 最後怎麼解決的此問題 ,求公布答案, 我也是碰到這個問題了,能模擬登錄成功並且獲取到cookie保存,然後總是返回登錄成功後 第一個看到的頁面,再獲取其他頁面就不行了,目標伺服器也是和你的問題一樣,通過session 來判斷

2. php curl 模擬登錄 失敗不成功 高手來解救!

請使用SNOOPY,你網路一下就有下載地址了他是對CURL的封裝,大網站很多都用這個

3. PHP模擬登陸QQ空間

PHP代碼:
<php
$qq = "100000"; //qq號碼
$pwd = "123456"; //密碼
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://211.139.167.71/waptest/TWF/qqportal/rela/updateuserinfo.jsp");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //這行是設定curl是否跟隨header發送的location, 重要
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, "Connection", "Keep-Alive");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "qq=".$qq."&pwd=".$pwd."&FromWhere=register");
$return = curl_exec($ch);
curl_close($ch);
echo strstr($return, "postfield") ? "登錄失敗" : "登錄成功";
?>
註:1、需curl模塊支持,2、登陸後,你的好友將會看到你在線 3、不知道如何下線。
其他語言的實現類似,有興趣的朋友可以自己動手開發一下。

這個你試試

4. php curl 無法實現模擬登陸

<?php
$discuz_url = 'http://127.0.0.1/discuz/';//論壇地址
$login_url = $discuz_url .'logging.php?action=login';//登錄頁地址

$post_fields = array();
//以下兩項不需要修改
$post_fields['loginfield'] = 'username';
$post_fields['loginsubmit'] = 'true';
//用戶名和密碼,必須填寫
$post_fields['username'] = 'tianxin';
$post_fields['password'] = '111111';
//安全提問
$post_fields['questionid'] = 0;
$post_fields['answer'] = '';
//@todo驗證碼
$post_fields['seccodeverify'] = '';
//獲取表單FORMHASH
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches);
if(!empty($matches)) {
$formhash = $matches[1];
} else {
die('Not found the forumhash.');
}

//POST數據,獲取COOKIE,cookie文件放在網站的temp目錄下
$cookie_file = tempnam('./temp','cookie');
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
//取到了關鍵的cookie文件就可以帶著cookie文件去模擬發帖,fid為論壇的欄目ID
$send_url = $discuz_url."post.php?action=newthread&fid=2";

$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
//這里的hash碼和登陸窗口的hash碼的正則不太一樣,這里的hidden多了一個id屬性
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*id="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches);
if(!empty($matches)) {
$formhash = $matches[1];
} else {
die('Not found the forumhash.');
}

$post_data = array();
//帖子標題
$post_data['subject'] = 'test2';
//帖子內容
$post_data['message'] = 'test2';
$post_data['topicsubmit'] = "yes";
$post_data['extra'] = '';
//帖子標簽
$post_data['tags'] = 'test';
//帖子的hash碼,這個非常關鍵!假如缺少這個hash碼,discuz會警告你來路的頁面不正確
$post_data['formhash']=$formhash;

$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_REFERER, $send_url); //偽裝REFERER
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$contents = curl_exec($ch);
curl_close($ch);
//清理cookie文件
unlink($cookie_file);
?>

熱點內容
三星3熱點密碼怎麼設置 發布:2024-04-20 16:30:52 瀏覽:578
用keil編譯顯示警告warn 發布:2024-04-20 16:27:09 瀏覽:893
訪問在哪兒 發布:2024-04-20 16:20:42 瀏覽:200
安卓手機有什麼可以把聲音改成電音的軟體 發布:2024-04-20 16:19:40 瀏覽:563
uc瀏覽器怎麼緩存視頻 發布:2024-04-20 16:10:44 瀏覽:80
邏輯錯誤預編譯可以檢查出來嗎 發布:2024-04-20 15:58:28 瀏覽:1000
mc中國版伺服器地址 發布:2024-04-20 15:33:13 瀏覽:411
手機修改wifi密碼網站是什麼 發布:2024-04-20 15:22:05 瀏覽:323
js源碼下載 發布:2024-04-20 15:05:16 瀏覽:20
編譯翻譯的區別 發布:2024-04-20 14:55:53 瀏覽:894