forked from openwpm/OpenWPM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpriv_crawl.py
More file actions
51 lines (39 loc) · 1.84 KB
/
priv_crawl.py
File metadata and controls
51 lines (39 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import absolute_import
from automation import TaskManager, CommandSequence
from six.moves import range
# How many browsers we wish to use
NUM_BROWSERS = 3
# Import urls from url_file into sites list
sites = []
# Read url_file as regular file, stripping newline
with open('/home/icebox/PycharmProjects/OpenWPM/data/top_50_rankless.csv', 'rU') as url_file:
for line in url_file:
sites.append(line.strip())
print(sites)
url_file.close()
# 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 range(NUM_BROWSERS):
# 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
# 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 all browsers simultaneously
for site in sites:
command_sequence = CommandSequence.CommandSequence(site, reset=True) # Stateless - resets after visit
# Start by visiting the page
command_sequence.get(sleep=0, timeout=60)
# dump_profile_cookies/dump_flash_cookies closes the current tab.
command_sequence.dump_profile_cookies(120)
# index='**' synchronizes visits between the three browsers
manager.execute_command_sequence(command_sequence, index='**')
# Shuts down the browsers and waits for the data to finish logging
manager.close()