我正在嘗試創建一個 Python 腳本,它將在數據庫中填充一些信息。對于服務器端,我使用了 PHP,當我嘗試使用瀏覽器提交信息時,它起作用了。但是當我嘗試使用下面的 Python 腳本執行此操作時,它沒有。import requestsurl_insert = 'http://192.168.1.100/index.php'data_insert = {'fullname':'spiderman', 'ssn':'1234', 'dept':'Security', 'salary':10000, 'homeaddress':'New York', 'btn_save':'Save'}req = requests.post(url_insert, data = data_insert)print(req.text)回復:Connected Successfully.<br><html><head><title>RETRIEVE DATA</title></head><body><form action="data.php" method="POST"> <div class="form-group"> <label for="id">Full Name</label> <input type="text" name="fullname" id="fullname" value="" placeholder="FullName"> <br> <br> <label for="id">Social Security Number</label> <input type="text" name="ssn" id="ssn" value="" placeholder="Social Security Number"> <br> <br> <label for="id">Department</label> <input type="text" name="dept" id="dept" value="" placeholder="Department"> <br> <br> <label for="id">Salary</label> <input type="text" name="salary" id="salary" value="" placeholder="Salary"> <br> <br> <label for="id">Address</label> <input type="text" name="homeaddress" id="homeaddress" value="" placeholder="Address"> <br> <br> <input type="submit" name="btn_save" value="Save"> </div></form></body></html>
1 回答

呼喚遠方
TA貢獻1856條經驗 獲得超11個贊
我將假設當您使用瀏覽器成功提交信息時,就是使用腳本生成的表單index.php
。
該 HTML 表單將來自用戶的數據輸入到字段名稱中,ssn
并將數據發布到腳本data.php
中。您的 Python 腳本同樣應該將數據發布到data.php
(但是,它似乎缺少 的數據fullname
)。但相反,您正在發布到index.php
. 然后我希望響應是您之前成功提交信息的 HTML 表單。看起來的確如此。
只需更改index.php
為data.php
并為其提供一個值fullname
。
- 1 回答
- 0 關注
- 97 瀏覽
添加回答
舉報
0/150
提交
取消