Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python
from __future__ import print_function
import json
import sys
from datetime import timedelta, datetime
from random import randint, choice
countries = ('US', 'GB', 'FR', 'DE',)
dlc = ('CSAIL', 'DUSP', 'Lincoln Lab',)
user_agents = ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/30.0.1599.114 Chrome/30.0.1599.114 Safari/537.36',)
def random_date(start, end):
delta = randint(0, int((end - start).total_seconds()))
return start + timedelta(seconds=delta)
def create_request():
request = {}
request['ip_address'] = '18.1.1.1'
request['time'] = random_date(datetime(2009, 1, 1), datetime.now()).isoformat()
request['request'] = 'http://example.com/id/{}'.format(randint(0, 100))
request['status'] = 200
request['referer'] = "http://example.com/"
request['user_agent'] = choice(user_agents)
request['dlc'] = choice(dlc)
request['author'] = "http://example.com/author/{}".format(randint(1000, 1200))
request['handle'] = "http://example.com/handle/{}".format(randint(0,100))
request['country'] = choice(countries)
return request
if __name__ == "__main__":
requests = sys.argv[1]
for i in range(0, int(requests)):
print(json.dumps(create_request()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.