Fork自 inscode / Python
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")