国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - php通過curl模擬登陸DZ論壇

php通過curl模擬登陸DZ論壇

2020-09-23 15:29PHP教程網 PHP教程

本文章來給各位同學介紹一下關于Php CURL模擬登陸論壇并采集數據實例,如果你對利用curl模擬登錄功能有興趣可進入參考。

libcurl同時也支持HTTPS認證、HTTP POST、HTTP PUT、 FTP 上傳(這個也能通過PHP的FTP擴展完成)、HTTP 基于表單的上傳、代理、cookies和用戶名+密碼的認證。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
$discuz_url = 'http://www.jfrwli.cn/';//論壇地址
$login_url = $discuz_url .'login.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);
?>

以上所述就是本文的全部內容了,希望大家能夠喜歡。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产成人免费视频网站高清观看视频 | 狠狠操电影| 色av中文字幕 | 久草视频网 | www.青青草| 午夜精品久久久久久久久久久久 | 色黄网站 | 国产一区二区在线视频 | 中文字幕高清在线播放 | 国产 欧美 日韩 一区 | 欧美午夜影院 | 欧美中文在线 | 在线成人免费视频 | 亚洲精品专区 | 久久精品伊人 | 2012中文版免费观看 | 一级黄色片欧美 | 久久一区二| 国产2区| 久久久国产一区二区 | 美女一区 | 色五月激情五月 | 国产成人精品一区二 | 91社区在线观看 | 国产玖玖| 日韩欧美高清视频 | 成人免费xxxxx在线视频软件 | av免费一区二区 | 欧美激情一区二区三区 | 国产精品永久免费视频 | 久久精品久久久久久 | 亚洲一区在线播放 | 狼人综合av | 久久亚洲一区 | 欧美在线观看成人 | 天天操天天干天天 | 亚洲福利 | 中国a一片一级一片 | 国产欧美一区二区视频 | 中文字幕一区二区三区久久 | 不卡一区 |