当前位置: 首页>>代码示例>>Python>>正文


Python DesiredCapabilities.PHANTOMJS属性代码示例

本文整理汇总了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!") 
开发者ID:rookiesmile,项目名称:python,代码行数:27,代码来源:qq_login.py

示例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() 
开发者ID:princewen,项目名称:python3_crawl,代码行数:15,代码来源:generator.py

示例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') 
开发者ID:princewen,项目名称:python3_crawl,代码行数:14,代码来源:generator.py

示例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
            ) 
开发者ID:LetItGrow,项目名称:Selenium-Phantomjs,代码行数:11,代码来源:JSspider.py

示例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() 
开发者ID:Python3WebSpider,项目名称:CookiesPool,代码行数:15,代码来源:generator.py

示例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 
开发者ID:yzyio,项目名称:adidas-multi-session,代码行数:10,代码来源:utils.py

示例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" 
开发者ID:v1n337,项目名称:stock-correlated-news-harvester,代码行数:14,代码来源:article_search_helper.py

示例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() 
开发者ID:xiaobeibei26,项目名称:weibo_cookies,代码行数:12,代码来源:get_cookie.py


注:本文中的selenium.webdriver.DesiredCapabilities.PHANTOMJS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。