是否可以使用selenium webdriver向服務器發送多個HTTP POST請求?Python:在同一頁面上發送多個POST請求
例如如果用戶ID是自動遞增,前1000名追隨者跟着我,那會是可以運行像在哪裏POST請求不返回裝載的網站如下:
* *該網站顯然需要用戶登錄才能執行此類操作,因此採用硒方法。
driver = webdriver.Firefox()
driver.get("http://example.com/myfollowers")
for userid in range(1, 1001):
driver.post("http://example.com/unfollow/{}".format(userid))
driver.close()
以下是對站點發布的發佈請求的代碼片段示例。
General:
Request URL:http://example.com/unfollow/1
Request Method:POST
Status Code:200 OK
Remote Address:192.168.1.1:80
Response Headers
Request headers:
Accept:*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Cookie:ob-i=1;
Host:example.com
Origin:http://example.com
Referer:http://example.com/user/followings
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.26.02 Safari/537.36
X-Requested-With:XMLHttpRequest
通過不返回一重裝我的意思是,它不提交表單並返回頁面刷新/新頁面(程序可以繼續在同一個選項卡中運行,而無需等待服務器響應)。 – AK47
然後這仍然會工作。最後一行中的「r.content」將爲空。 –