當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。