Skip to content

Instantly share code, notes, and snippets.

@dertin
Last active November 29, 2018 02:11
Show Gist options
  • Save dertin/94b87b31b8e9eb0f1a771d5493510ff8 to your computer and use it in GitHub Desktop.
Save dertin/94b87b31b8e9eb0f1a771d5493510ff8 to your computer and use it in GitHub Desktop.
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