是否可以使用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”将为空。 –