本文整理汇总了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()