我已經買了一個小的WiFi中繼模塊 - 雖然它是中文,我不讀我已經制定了如何打開和關閉從嵌入式網頁主頁上的按鈕的繼電器服務器。郵差不工作的Python腳本
然後我使用郵差攔截器來捕獲「開放」和「關閉」動作,現在我可以點擊'發佈'按鈕來使動作發生。
但'生成代碼'python腳本不起作用,並從我有限的理解沒有正確的信息。
import requests
url = "http://192.168.4.1/"
payload = ""
headers = {
'origin': "http://192.168.4.1",
'upgrade-insecure-requests': "1",
'user-agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
'content-type': "application/x-www-form-urlencoded",
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
'dnt': "1",
'referer': "http://192.168.4.1/",
'accept-encoding': "gzip, deflate",
'accept-language': "en-US,en;q=0.8",
'cache-control': "no-cache",
'postman-token': "bece04e7-ee50-3764-ca50-e86d07ebc0f3"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
輸出,當我選擇的,而不是Python的HTTP請求是
POST/HTTP/1.1
Host: 192.168.4.1
Origin: http://192.168.4.1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
DNT: 1
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cache-Control: no-cache
Postman-Token: 0bd42b4f-067d-b5be-dd1c-b7e689196043
open_relay=%EF%BF%BD%F2%BF%AA%BC%CC%B5%EF%BF%BD%EF%BF%BD%EF%BF%BD
可能有人建議如何修改Python來正確發送它從郵遞員本身工作正常的POST?
我相信你需要把'open_relay =%EF%BF%BD%F2%BF%AA%BC%CC%B5%EF你的python代碼中的'payload'變量中的%BF%BD%EF%BF%BD%EF%BF%BD'。 – nvioli
請注意,該數據似乎是GB-2312編碼的以url引用的值。 –
是的,將該文本粘貼到有效負載變量中 - 非常感謝 - 我是一個完整的新手 - 如何標記回答的問題,給予榮譽等等? – point5Clue