Created
June 30, 2020 22:23
-
-
Save bdnf/ef3192f1de2289f8e5e3735c802bff5d to your computer and use it in GitHub Desktop.
Generate clickstream events
This file contains 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 requests | |
import random | |
import sys | |
import argparse | |
def getClicked(rate): | |
if random.random() <= rate: | |
return True | |
else: | |
return False | |
def httpGetImpression(): | |
url = args.target + '?browseraction=Impression' | |
r = requests.get(url) | |
def httpGetClick(): | |
url = args.target + '?browseraction=Click' | |
r = requests.get(url) | |
sys.stdout.write('+') | |
parser = argparse.ArgumentParser() | |
parser.add_argument("target",help="<http...> the http(s) location to send the GET request") | |
args = parser.parse_args() | |
i = 0 | |
while (i < 2500): | |
httpGetImpression() | |
if(i<1950 or i>=2000): | |
clicked = getClicked(.1) | |
sys.stdout.write('_') | |
else: | |
clicked = getClicked(.5) | |
sys.stdout.write('-') | |
if(clicked): | |
httpGetClick() | |
i = i + 1 | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment