Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def webshot(args):
"""
Mass web screenshot function
"""
targets = [url.rstrip() for url in args.f]
timeout = args.t
# set up headless browser
try:
browser = webdriver.PhantomJS(
service_log_path=os.path.devnull,
service_args=["--ignore-ssl-errors=true"])
browser.set_page_load_timeout(timeout)
browser.set_window_size(1920, 1080)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
sys.exit(1)
# create output directory
outdir = "webshots-" + time.strftime("%Y%m%d-%H%M%S", time.localtime())
try:
os.mkdir(outdir, mode=0o755)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
'''
Created on Dec 6, 2013
@author: Jay
@description: use PhantomJS to parse a web page to get the geo info of an IP
For PhantomJS, please visit: http://phantomjs.org/
'''
from selenium import webdriver
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
driver = webdriver.PhantomJS(executable_path='./phantomjs')
driver.get("http://www.ip.cn/125.95.26.81")
#print driver.current_url
#print driver.page_source
print driver.find_element_by_id('result').text.split('\n')[0].split('来自:')[1]
#text = driver.find_element_by_xpath('//div[@id="result"]/div/p').text
#result = text.split('来自:')[1]
#print result
driver.quit
def start(self):
try:
if self.login :
browser = webdriver.PhantomJS()
cookie=self.cookie
cookies=cookie.split(";")
all_cookies = browser.get_cookies()
for c in cookies:
c_name=c.split("=")[0]
c_value=c.split("=")[1]
ck={'domain':self.base,'name':c_name,'value':c_value,'httponly': False, 'secure': False,'path':'/dvwa/'}
browser.delete_cookie(c_name)
browser.add_cookie(ck)
browser.get(self.target) #To ensure referer is set
browser.get(self.target_link)
else:
def grabCurrentTitle(url):
#this grabs the title of the splash page
driver = webdriver.PhantomJS()
# Creates new webdriver instance
driver.get(url)
# Navigates to the user
title = driver.title
# Gets the title. eg: Adidas | Page Not Found
driver.close()
# Closes out the webdriver
driver.quit()
# Closes out the webdriver
return title
# Returns the title as a string
return profiles
try:
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
profiles = get_all_profiles()
profile = self.repo.repo_name()
if not self.repo.name.startswith('drupal/'):
if profile not in profiles:
profile = profiles[0]
LOG.info('Profile: {}'.format(profile))
browser = webdriver.PhantomJS()
browser.get('http://127.0.0.1:{port}/install.php?profile={profile}&welcome=done&locale=en'.format(port = self.port, profile = profile))
t = threading.Thread(target = check_drupal_status, args = (self, ))
t.daemon = True
t.start()
database_tag_name = {
'MySQL': 'mysql',
'PostgreSQL': 'pgsql',
'SQLite3': 'sqlite'
}.get(self.database.name, 'mysql')
# heuristical
while True:
if self.drupal_has_installed():
break
kwargs.update({'executable_path': binary})
self._webdriver = webdriver.Firefox(**kwargs)
elif self.browser == 'ie':
if binary:
kwargs.update({'executable_path': binary})
self._webdriver = webdriver.Ie(**kwargs)
elif self.browser == 'edge':
if binary:
kwargs.update({'executable_path': binary})
capabilities = webdriver.DesiredCapabilities.EDGE.copy()
capabilities['acceptSslCerts'] = True
capabilities['javascriptEnabled'] = True
kwargs.update({'capabilities': capabilities})
self._webdriver = webdriver.Edge(**kwargs)
elif self.browser == 'phantomjs':
self._webdriver = webdriver.PhantomJS(
service_args=['--ignore-ssl-errors=true'])
if self._webdriver is None:
raise ValueError(
'"{}" webdriver is not supported. Please use one of {}'
.format(
self.browser,
('chrome', 'firefox', 'ie', 'edge', 'phantomjs')
)
)
self._set_session_cookie()
return self._webdriver
def youtube_download_via_url(base_url):
logger.addLog ("Starting web driver")
driver = webdriver.PhantomJS(service_args=['--load-images=false'])
logger.addLog ("Webdriver started")
# bitly = bitly_api.Connection(access_token=bitly_token)
# url_error = False
# if base_url.find("http") < 0 and base_url.find("youtu") >= 0:
# base_url = "http://" + base_url
# url_error = True
# else:
# url_error = True
# if base_url.find("://youtu.be/") > 3:
# base_url = base_url.replace("youtu.be/", "getlinkyoutube.com/watch?v=")
# url_error=True
# elif base_url.find("youtube.com/watch") > 6:
# base_url = base_url.replace("youtube" , "getlinkyoutube") #changing supplied youtube url to redirect it to youtubemultidownload
# url_error=True
# else:
# url_error = True
def __init__(self):
self.driver = webdriver.PhantomJS()
self.driver.set_window_size(1120, 550)
def create_phantomjs(self, desired_capabilities, remote_url, options=None, service_log_path=None):
warnings.warn('SeleniumLibrary support for PhantomJS has been deprecated, '
'please use headlesschrome or headlessfirefox instead.')
if is_truthy(remote_url):
defaul_caps = webdriver.DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities = self._remote_capabilities_resolver(desired_capabilities, defaul_caps)
return self._remote(desired_capabilities, remote_url)
if options:
logger.warn('PhantomJS browser does not support Selenium options.')
return webdriver.PhantomJS(service_log_path=service_log_path, **desired_capabilities)