Seleniumシミュレーション上陸爬虫類

1486 ワード

テクニカルコース:selenium+Chrome
注意事項:
1、chromeバージョン(chrome://version/)とchromedriverバージョンのマッチング.バージョン照合リファレンスhttps://blog.csdn.net/huilan_same/article/details/51896672
2、windows:ドライバをダウンロードしてパスD:AnacondaLibrarybinにコピーし、公式IDLEはD:Pythonにコピーし、環境変数を設定する必要がなく、driver=webdriver.Chrome()の「()」にパスを入力
# selenium     

'''
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")       # define headless
driver = webdriver.Chrome(chrome_options=chrome_options)
                    
'''

from selenium import webdriver
from bs4 import BeautifulSoup
driver=webdriver.Chrome()   #   chrome   

#        
driver.get("https://account.xiaomi.com/pass/serviceLogin?callback=https%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252Fredminote7%252F%26sign%3DYWM1Y2MyNjllNzA2NWNkMjJjOTg3NWQyMmI5YTBjMGZjYmRlNWNjMQ%2C%2C&sid=mi_eshop&_bannerBiz=mistore&_qrsize=180")

#      
driver.find_element_by_xpath('//*[@id="username"]').clear()
driver.find_element_by_xpath('//*[@id="username"]').send_keys("************")
#       
driver.find_element_by_xpath('//*[@id="pwd"]').clear()
driver.find_element_by_xpath('//*[@id="pwd"]').send_keys("**************")


driver.find_element_by_xpath('//*[@id="login-button"]').click()