咱们先来安装一下git
pip install selenium
接着咱们还要下载浏览器驱动 我用的是Firefox浏览器,因此下载Firefox驱动,固然你用别的浏览器也阔以,去相应的地方下载就好了 Chrome | https://sites.google.com/a/chromium.org/chromedriver/downloads ------------- | ------------- Edge: | https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Firefox: | https://github.com/mozilla/geckodriver/releases Safari: | https://webkit.org/blog/6900/webdriver-support-in-safari-10/github
下载完以后,将geckodriver
放到/usr/local/bin
目录下(我是用fedora桌面)web
#coding=utf-8 from selenium import webdriver import time driver = webdriver.Firefox() # oepn firefox driver.get('https://developer.apple.com/account/') # ask url time.sleep(17) #waiting for web loading driver.switch_to.frame('aid-auth-widget') # change into iframe driver.find_element_by_id('account_name_text_field').send_keys('511220@sohu.com') # insert appid driver.find_element_by_id('sign-in').click() # click to continue driver.find_element_by_id('remember-me').click() # click remember me driver.find_element_by_id('password_text_field').send_keys('19942929') # insert password time.sleep(3) # sleep for url change driver.find_element_by_id('sign-in').click() # click to sign in