def __init__(self, user_agent=None, cookies_file=None):
"""
Initialize the phantom JS selenium driver
:return:
"""
self.conf = config
self.user_agent = user_agent
self.cookies_file = cookies_file
# http://phantomjs.org/api/webpage/property/settings.html
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap['phantomjs.page.settings.loadImages'] = False
dcap['phantomjs.page.settings.webSecurityEnabled'] = False
dcap['phantomjs.page.settings.localToRemoteUrlAccessEnabled'] = True
if user_agent:
dcap['phantomjs.page.settings.userAgent'] = user_agent
self.driver = webdriver.PhantomJS(
desired_capabilities=dcap,
executable_path=self.conf['general']['phantomjs'],
)
self.load_cookies()
self.driver.implicitly_wait(30)
self.driver.set_window_size(1024, 768)
评论列表
文章目录