【三】【selenium+python】賬號登入頁面並重新整理頁面
阿新 • • 發佈:2019-01-06
#!coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Chrome()
#driver = webdriver.Firefox()
driver.get("http://pc.s2btest.kstore.shop/login")
time.sleep(2)
#輸入賬號密碼
driver.find_element_by_xpath("//*[@id='account']").send_keys("18795901111")
time.sleep(1)
driver.find_element_by_xpath("//*[@id='password']").send_keys("qianmi520")
time.sleep(1)
#單擊登入按鈕
driver.find_element_by_xpath("//*[@id='page-content']/div[1]/div[2]/div[2]/form/div[3]/div/div/button").click()
#商品詳情頁重新整理3000次
n=3000
while n>1:
driver.refresh()
n=n-1
time.sleep(1)
driver.quit()
from selenium import webdriver
import time
driver = webdriver.Chrome()
#driver = webdriver.Firefox()
driver.get("http://pc.s2btest.kstore.shop/login")
time.sleep(2)
#輸入賬號密碼
driver.find_element_by_xpath("//*[@id='account']").send_keys("18795901111")
time.sleep(1)
driver.find_element_by_xpath("//*[@id='password']").send_keys("qianmi520")
time.sleep(1)
#單擊登入按鈕
driver.find_element_by_xpath("//*[@id='page-content']/div[1]/div[2]/div[2]/form/div[3]/div/div/button").click()
time.sleep(1)
#單擊一個商品,進入商品詳情頁
driver.find_element_by_xpath("//*[@id='page-content']/div[1]/div[2]/div[2]/div/div/ul/li[7]/div/div[2]/a/span").click()#商品詳情頁重新整理3000次
n=3000
while n>1:
driver.refresh()
n=n-1
time.sleep(1)
driver.quit()