-
-
Save dertin/94b87b31b8e9eb0f1a771d5493510ff8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from locust import HttpLocust, TaskSet, task | |
class WebsiteTasks(TaskSet): | |
@task | |
def index(self): | |
# UPDATE WITH YOUR GOOGLE COOKIE FOR TESTING | |
raw_google_cookie = 'SID=...;HSID=...;SSID=...;' | |
with self.client.request(method="POST", | |
url="/_/SocialPeopleHovercardUi/data/batchexecute", | |
data={ | |
"f.req": "[]" | |
}, | |
headers={ | |
"Cookie": raw_google_cookie | |
}, | |
catch_response=True | |
) as response: | |
if response.status_code not in [200, 400]: | |
response.failure(response) | |
else: | |
response.success() | |
print(response.text) | |
def track_success(**kwargs): | |
print(kwargs) | |
class WebsiteUser(HttpLocust): | |
task_set = WebsiteTasks | |
min_wait = 5000 | |
max_wait = 15000 | |
# Usage | |
# pip install locustio | |
# locust --host=https://contacts.google.com -f unusual-traffic-test.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment