導航:首頁 > 編程語言 > php模擬提交表單

php模擬提交表單

發布時間:2022-08-11 12:24:33

php curl 模擬post表單向提交數據

不需要抓取數據的話,就只要分析一下對方網站表單需要的欄位,然後把action的地址改成對方網站的就提交路徑就行了,但如果對方網站提交時要獲取cookie的話才需要用curl

㈡ PHP 如何帶上cookies模擬GET表單提交

$querystring = "key1=value1&key2=value2"; //get方式querystring

$cookie_jar='' //手動登陸一次後獲取cookie文件路徑,,這里填寫cookie路徑

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://1.2.3.4/loginstudent.action?$querystring");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$result=curl_exec($ch);
curl_close($ch);

㈢ PHP里模擬Post提交是什麼意思

php
表單提交常見的就是post和get
模擬提交就是通過其他技術達到post或get的效果
php
常見的模擬就是curl方式了
作用比如說刷票
每次提交它可以模擬ip
逃過ip限制
圖片上傳
可以post提交
不用模擬

㈣ 用php代碼方式模擬提交文字加圖片的表單怎麼實現的

使用PHP的cURL庫,或者
snoopy類
這兩種都可以試試。具體使用方式網上很多,搜一下。

㈤ 請教用Curl 在php 裡面模擬表單提交 文本+文件的寫法

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

public function curl($url, $postFields = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($this->readTimeout) {
curl_setopt($ch, CURLOPT_TIMEOUT, $this->readTimeout);
}
if ($this->connectTimeout) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
}
//https 請求
if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}

if (is_array($postFields) && 0 < count($postFields))
{
$postBodyString = "";
$postMultipart = false;
foreach ($postFields as $k => $v)
{
if("@" != substr($v, 0, 1))//判斷是不是文件上傳
{
$postBodyString .= "$k=" . urlencode($v) . "&";
}
else//文件上傳用multipart/form-data,否則用www-form-urlencoded
{
$postMultipart = true;
}
}
unset($k, $v);
curl_setopt($ch, CURLOPT_POST, true);
if ($postMultipart)
{
foreach ($postFields as $k => $v){
if ("@" == substr($v, 0, 1)){
$tempffile = preg_replace ('/^\@/' ,'' ,$v);
$advfield[$k] = new CURLFile($tempffile);
}else {
$advfield[$k] = $v;
}
}

curl_setopt($ch, CURLOPT_POSTFIELDS, $advfield);
unset($k, $v, $advfield);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); //田村改
//curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => new CURLFile(realpath('image.png'))]);
}
else
{
curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1));
}
}
$reponse = curl_exec($ch);

if (curl_errno($ch))
{
throw new Exception(curl_error($ch),0);
}
else
{
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode)
{
throw new Exception($reponse,$httpStatusCode);
}
}
curl_close($ch);
return $reponse;
}

表單列表是 $postFields 傳入參數
數組,如果有文件 ,就在數組的值 前面加@

已經做好的 集成類 的實現 其他類欄位和方法沒給出,寫不下了。
但是大致的實現過程應該可以看懂了

㈥ PHP如何實現向指定頁面填寫表單並提交就是發貼

給你指定思路:先建立表單(表單使用POST方式提交)----
在POST提交的方法里對表單進行獲取值($title
=
$_REQUEST['title'])----
再將獲取到的值保存到資料庫里就行了

閱讀全文

與php模擬提交表單相關的資料

熱點內容
怎樣把名字變成文件夾 瀏覽:199
文件怎麼搞成文件夾 瀏覽:726
多線程編程php 瀏覽:602
安卓機越用越卡有什麼辦法 瀏覽:7
高中生解壓操場適合做的游戲 瀏覽:391
程序員java招聘 瀏覽:446
未來之光手機雲伺服器 瀏覽:158
伺服器下載資料為什麼c盤滿了 瀏覽:263
怎麼清除空文件夾 瀏覽:544
如何查看派派伺服器 瀏覽:802
殺手6解壓畫面 瀏覽:669
誇張程序員 瀏覽:467
如何直播切兩個APP畫面 瀏覽:784
4x4測試伺服器怎麼獲得 瀏覽:740
開環與閉環python 瀏覽:517
蘋果手機上的東西怎麼加密 瀏覽:554
坐過牢可以做程序員嗎 瀏覽:254
男友是程序員女友是自由職業 瀏覽:272
娃娃智慧閱讀源碼 瀏覽:163
程序員敲響警鍾 瀏覽:888