Demo entry 6334658

demo.py

   

Submitted by anonymous on Dec 06, 2016 at 04:49
Language: Python. Code size: 1.2 kB.

from automation import TaskManager

# The list of sites that we wish to crawl
NUM_BROWSERS = 6
sites = ['http://www.foxnews.com/',
         'http://www.cnn.com/',
	 'http://www.usatoday.com/',
	 'http://www.bbc.com/news']

# Loads the manager preference and 3 copies of the default browser dictionaries
manager_params, browser_params = TaskManager.load_default_params(NUM_BROWSERS)

# Update browser configuration (use this for per-browser settings)
for i in xrange(NUM_BROWSERS):
    browser_params[i]['disable_flash'] = False #Enable flash for all three browsers
browser_params[0]['headless'] = True #Launch only browser 0 headless

# Update TaskManager configuration (use this for crawl-wide settings)
manager_params['data_directory'] = '~/Desktop/'
manager_params['log_directory'] = '~/Desktop/'

# Instantiates the measurement platform
# Commands time out by default after 60 seconds
manager = TaskManager.TaskManager(manager_params, browser_params)

# Visits the sites with both browsers simultaneously
for site in sites:
    manager.get(site, index='**') # ** = synchronized browsers

# Shuts down the browsers and waits for the data to finish logging
manager.close()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).