導航:首頁 > 編程語言 > 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模擬提交表單相關的資料

熱點內容
資料庫查詢系統源碼 瀏覽:614
php5314 瀏覽:354
完美國際安裝到哪個文件夾 瀏覽:666
什麼app可以掃一掃做題 瀏覽:537
程序員編碼論壇 瀏覽:923
淘點是什麼app 瀏覽:658
中國高等植物pdf 瀏覽:453
51單片機時間 瀏覽:181
後台如何獲取伺服器ip 瀏覽:265
單片機流水燈程序c語言 瀏覽:232
程序員第二職業掙錢 瀏覽:237
運行里怎麼輸入伺服器路徑 瀏覽:840
pythonstepwise 瀏覽:508
劉一男詞彙速記指南pdf 瀏覽:62
php認證級別 瀏覽:366
方舟編譯啥時候推送 瀏覽:1009
php手機驗證碼生成 瀏覽:675
哲學思維pdf 瀏覽:14
凌達壓縮機有限公司招聘 瀏覽:534
weblogic命令部署 瀏覽:36