from locust import HttpUser, TaskSet, task import urllib3 urllib3.disable_warnings() class UserBehavior(TaskSet): def on_start(self): print("start****") def on_stop(self): print("stop****") @task(1) def baidu_page1(self): res = self.client.get("/", verify=False) class WebsiteUser(HttpUser): tasks = [UserBehavior] host = "https://www.baidu.com" min_wait = 1000 max_wait = 2000 if __name__ == '__main__': import os # os.system("locust -f main.py --host=https://www.baidu.com --headless -u 5 -r 1 --run-time 100s --stop-timeout 99") os.system("locust -f main.py --host=https://www.baidu.com")