How can I call the function "extract_links"?
As the title says when I want to call the function extract_links of Available Commands, I get the error to remind.
The error is as follows:
Traceback (most recent call last):
File "linktest.py", line 48, in <module>
command_sequence.extract_links()
AttributeError: 'CommandSequence' object has no attribute 'extract_links'
My code is as follows:
from automation import CommandSequence, TaskManager
# The list of sites that we wish to crawl
NUM_BROWSERS = 1
sites = [
'https://www.naijavibes.com/'
]
# Loads the default manager params
# and NUM_BROWSERS copies of the default browser params
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
# Record cookie changes
browser_params[i]['cookie_instrument'] = True
# Record Navigations
browser_params[i]['navigation_instrument'] = True
# Record JS Web API calls
browser_params[i]['js_instrument'] = True
# Record the callstack of all WebRequests made
browser_params[i]['callstack_instrument'] = True
# Launch only browser 0 headless
browser_params[0]['display_mode'] = 'native'
# 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
for site in sites:
# Parallelize sites over all number of browsers set above.
command_sequence = CommandSequence.CommandSequence(
site, reset=True,
callback=lambda success, val=site:
print("CommandSequence {} done".format(val)))
# Start by visiting the page
command_sequence.get(sleep=3, timeout=60)
command_sequence.extract_links()
# Run commands across the three browsers (simple parallelization)
manager.execute_command_sequence(command_sequence)
# Shuts down the browsers and waits for the data to finish logging
manager.close()
Just added a line below the get function. When I try other functions such as dump_page_source, it all just ok. I want to know what is wrong with this and what I can do to fix this.
Thank you.
As the error message states there is no function called extract_links on the CommandSequence. Where did you get the impression that such a function does exist?
This function used to exist but was removed in https://github.com/mozilla/OpenWPM/pull/213. I've updated the wiki to remove reference to it. Let me know if we reference it anywhere else!