尝试使用Locust登录laravel应用程序。
我的代码如下: p>
< pre> 但是我收到错误 - Code 419 Content 该页面由于不活动而过期。
任何人都可以告诉我如何 使用Locust p>
div>登录Laravel应用程序来自locust import HttpLocust,TaskSet,task
class UserBehavior(TaskSet):
def on_start(self):
self.login()
def login(self):
响应 = self.client.get(“/ en / login”)
csrftoken = response.cookies ['XSRF-TOKEN']
session = response.cookies ['bitrent_session']
post_data = {'username':“ user@user.com“,'password':'1234',”_ token“:csrftoken}
,其中self.client.post('/ en / login',post_data,
catch_response = True)作为响应:
print(“Code:”,response.status_code)
print(“Content:”,response.content
@task()
def index(self):
self.client.get(“/” )
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
code> pre>
Trying to login to laravel application using Locust. My code is following:
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
self.login()
def login(self):
response = self.client.get("/en/login")
csrftoken = response.cookies['XSRF-TOKEN']
session = response.cookies['bitrent_session']
post_data = {'username': "user@user.com", 'password': '1234', "_token": csrftoken }
with self.client.post('/en/login', post_data,
catch_response=True) as response:
print("Code: ", response.status_code)
print("Content: ", response.content
@task()
def index(self):
self.client.get("/")
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
However I got error - Code 419 Content The page has expired due to inactivity. Could anyone advise me how to login to Laravel application using Locust