2017-03-09 19:00:54 +03:00
|
|
|
from __future__ import absolute_import
|
2018-08-15 17:30:21 +03:00
|
|
|
|
2017-03-09 19:00:54 +03:00
|
|
|
from six.moves import range
|
2014-07-01 20:37:17 +04:00
|
|
|
|
2018-08-01 09:48:06 +03:00
|
|
|
from automation import CommandSequence, TaskManager
|
|
|
|
|
2014-07-01 20:37:17 +04:00
|
|
|
# The list of sites that we wish to crawl
|
|
|
|
NUM_BROWSERS = 3
|
2016-05-04 18:46:15 +03:00
|
|
|
sites = ['http://www.example.com',
|
|
|
|
'http://www.princeton.edu',
|
|
|
|
'http://citp.princeton.edu/']
|
2014-07-01 20:37:17 +04:00
|
|
|
|
2015-09-14 18:05:50 +03:00
|
|
|
# Loads the manager preference and 3 copies of the default browser dictionaries
|
|
|
|
manager_params, browser_params = TaskManager.load_default_params(NUM_BROWSERS)
|
2014-07-01 20:37:17 +04:00
|
|
|
|
2015-09-14 18:05:50 +03:00
|
|
|
# Update browser configuration (use this for per-browser settings)
|
2017-03-09 19:00:54 +03:00
|
|
|
for i in range(NUM_BROWSERS):
|
2017-07-28 23:37:35 +03:00
|
|
|
# Record HTTP Requests and Responses
|
|
|
|
browser_params[i]['http_instrument'] = True
|
|
|
|
# Enable flash for all three browsers
|
|
|
|
browser_params[i]['disable_flash'] = False
|
|
|
|
browser_params[0]['headless'] = True # Launch only browser 0 headless
|
2014-07-01 20:37:17 +04:00
|
|
|
|
2015-09-14 18:05:50 +03:00
|
|
|
# Update TaskManager configuration (use this for crawl-wide settings)
|
|
|
|
manager_params['data_directory'] = '~/Desktop/'
|
|
|
|
manager_params['log_directory'] = '~/Desktop/'
|
2014-07-01 20:37:17 +04:00
|
|
|
|
|
|
|
# Instantiates the measurement platform
|
|
|
|
# Commands time out by default after 60 seconds
|
2015-09-14 18:05:50 +03:00
|
|
|
manager = TaskManager.TaskManager(manager_params, browser_params)
|
2014-07-01 20:37:17 +04:00
|
|
|
|
2016-05-03 23:54:42 +03:00
|
|
|
# Visits the sites with all browsers simultaneously
|
2014-07-01 20:37:17 +04:00
|
|
|
for site in sites:
|
2015-11-24 18:13:38 +03:00
|
|
|
command_sequence = CommandSequence.CommandSequence(site)
|
2016-10-27 17:56:03 +03:00
|
|
|
|
|
|
|
# Start by visiting the page
|
2016-05-03 23:54:42 +03:00
|
|
|
command_sequence.get(sleep=0, timeout=60)
|
2016-10-27 17:56:03 +03:00
|
|
|
|
|
|
|
# dump_profile_cookies/dump_flash_cookies closes the current tab.
|
2016-05-03 19:21:26 +03:00
|
|
|
command_sequence.dump_profile_cookies(120)
|
2016-10-27 17:56:03 +03:00
|
|
|
|
2017-07-28 23:37:35 +03:00
|
|
|
# index='**' synchronizes visits between the three browsers
|
|
|
|
manager.execute_command_sequence(command_sequence, index='**')
|
2014-07-01 20:37:17 +04:00
|
|
|
|
|
|
|
# Shuts down the browsers and waits for the data to finish logging
|
|
|
|
manager.close()
|