本文整理匯總了Python中selenium.webdriver.PhantomJS.maximize_window方法的典型用法代碼示例。如果您正苦於以下問題:Python PhantomJS.maximize_window方法的具體用法?Python PhantomJS.maximize_window怎麽用?Python PhantomJS.maximize_window使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類selenium.webdriver.PhantomJS
的用法示例。
在下文中一共展示了PhantomJS.maximize_window方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: catalog_url
# 需要導入模塊: from selenium.webdriver import PhantomJS [as 別名]
# 或者: from selenium.webdriver.PhantomJS import maximize_window [as 別名]
def catalog_url(url='http://www.meitun.com/'):
# catalog_url is AJAX,use phantomJS
driver = PhantomJS()
driver.get(url)
driver.maximize_window()
mov_ele = driver.find_element_by_css_selector('.nav>ul>li:nth-child(1)')
# the mouse move to the lazy layout element,and perform
ActionChains(driver).move_to_element(mov_ele).perform()
time.sleep(3)
response = driver.page_source
driver.quit()
# use pyquery parser the page source,more quickly
d = pq(response)
return map(lambda x: 'http:' + pq(x).attr('href'), d.find('.cg-pdts a'))
示例2: on_start_again
# 需要導入模塊: from selenium.webdriver import PhantomJS [as 別名]
# 或者: from selenium.webdriver.PhantomJS import maximize_window [as 別名]
def on_start_again(self, url):
driver = PhantomJS()
driver.get(url)
time.sleep(2)
driver.maximize_window()
t = driver.find_element_by_css_selector('.page-txt').text
res_t = []
if t:
t = int(t.split('/')[1][:-1]) - 1 # get the page count
# the count of page turning should be i-1
while t:
t -= 1
move_ele = driver.find_element_by_css_selector('#next')
ActionChains(driver).move_to_element(move_ele).click()
time.sleep(1)
res_t.append(driver.page_source)
driver.quit()
for item in res_t:
self.step_first(item)