本文整理匯總了Python中selenium.webdriver.DesiredCapabilities.PHANTOMJS屬性的典型用法代碼示例。如果您正苦於以下問題:Python DesiredCapabilities.PHANTOMJS屬性的具體用法?Python DesiredCapabilities.PHANTOMJS怎麽用?Python DesiredCapabilities.PHANTOMJS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類selenium.webdriver.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.PHANTOMJS屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def __init__(self,username="",password="",sqlroot='',sqlpassword=''):
self.username= username
self.password = password
self.headers = {
"user-agent": "Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255"}
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = (
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
'*/*',
'en-US,en;q=0.8',
'max-age=0',
'keep-alive'
)
self.browser = webdriver.PhantomJS(executable_path=r"phantomjs-2.1.1-windows\bin\phantomjs.exe",desired_capabilities=dcap)
self.browser.set_window_size(480,500)
self.browser.get("https://mobile.qzone.qq.com")
try:
self.sql = Sql(sqlroot, sqlpassword)
except pymysql.err.OperationalError:
print("???????????!")
root = input("?????: ")
password = input("?????: ")
self.sql = Sql(root,password)
print("Start!")
示例2: _init_browser
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def _init_browser(self, browser_type):
"""
??browser?????????????????
:param browser: ??? PhantomJS/ Chrome
:return:
"""
if browser_type == 'PhantomJS':
caps = DesiredCapabilities.PHANTOMJS
caps[
"phantomjs.page.settings.userAgent"] = "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
self.browser = webdriver.PhantomJS(desired_capabilities=caps)
elif browser_type == 'Chrome':
self.browser = webdriver.Chrome()
示例3: _init_browser
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def _init_browser(self, browser_type):
"""
??browser?????????????????
:param browser: ??? PhantomJS/ Chrome
:return:
"""
if browser_type=='PhantomJs':
caps = DesiredCapabilities.PHANTOMJS
caps["phantomjs.page.settings.userAgent"] = "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
self.browser = webdriver.PhantomJS(desired_capabilities=caps)
else:
self.browser = webdriver.Chrome('/usr/local/Cellar/chrome/chromedriver')
示例4: __init__
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def __init__(self):
self.dcap = dict(DesiredCapabilities.PHANTOMJS)
self.dcap["phantomjs.page.settings.loadImages"] = False
self.dcap["phantomjs.page.settings.resourceTimeout"] = 5000
self.re_userAgent()
self.driver = webdriver.PhantomJS(
desired_capabilities=self.dcap,
service_args=service_args
)
示例5: init_browser
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def init_browser(self):
"""
??browser?????????????????
:return:
"""
if BROWSER_TYPE == 'PhantomJS':
caps = DesiredCapabilities.PHANTOMJS
caps[
"phantomjs.page.settings.userAgent"] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
self.browser = webdriver.PhantomJS(desired_capabilities=caps)
self.browser.set_window_size(1400, 500)
elif BROWSER_TYPE == 'Chrome':
self.browser = webdriver.Chrome()
示例6: get_desired_capabilities_phantom
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def get_desired_capabilities_phantom(user_agent):
desired_capabilities = dict(DesiredCapabilities.PHANTOMJS)
desired_capabilities['phantomjs.page.settings.userAgent'] = user_agent
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = user_agent
desired_capabilities['phantomjs.page.customHeaders.customHeaders'] = \
{'Accept': 'text/html', 'Content-type': 'text/html', 'Cache-Control': 'max-age=0'}
return desired_capabilities
示例7: __init__
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def __init__(self):
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"
self.driver = webdriver.PhantomJS(desired_capabilities=dcap, executable_path="/usr/bin/phantomjs")
# chromedriver = "/home/v2john/Tools/chromedriver"
# os.environ["webdriver.chrome.driver"] = chromedriver
# self.driver = webdriver.Chrome(chromedriver)
self.timeout_seconds = 10
self.search_url = "https://news.google.com/news/advanced_news_search"
示例8: _init_browser
# 需要導入模塊: from selenium.webdriver import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.DesiredCapabilities import PHANTOMJS [as 別名]
def _init_browser(self,browser_type):
if browser_type == 'PhantomJS':
caps = DesiredCapabilities.PHANTOMJS#?????
caps[
"phantomjs.page.settings.userAgent"] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36'
self.browser = webdriver.PhantomJS(desired_capabilities=caps)
self.browser.set_window_size(1400, 500)
elif browser_type =='Chrome':
self.browser = webdriver.Chrome()