複数のHTTP POST要求をselenium webdriverを使用してサーバーに送信できますか?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'は空になります。 –