Skip to content

Instantly share code, notes, and snippets.

@gologius
Last active March 10, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gologius/9d70f8d7d501179cb468be440d09e7b0 to your computer and use it in GitHub Desktop.
Save gologius/9d70f8d7d501179cb468be440d09e7b0 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#########################
#パラメータ
CHROME_DRIVER_PATH = "chromedriver_win32\chromedriver.exe"
URL = "http://xxx"
WAIT_SEC = 10 #要素が見つかるまで最大何秒待つか
#########################
#関数定義
def __main__():
print("begin process")
driver = webdriver.Chrome(CHROME_DRIVER_PATH)
driver.implicitly_wait(WAIT_SEC)
driver.get(URL)
#ページ数を指定する
input_page = driver.find_element_by_xpath("//input[@id='page']")
input_pagemin.send_keys("1")
#ダウンロードボタンを押す
input_submit_btn = driver.find_element_by_xpath("//a[@onclick='download();']")
input_submit_btn.click()
#ポップアップ先のボタンを押す
win = driver.window_handles[-1] #リストの最後=最後に開いたウインドウ
driver.switch_to.window(win)
driver.find_element_by_xpath("//input[@type='submit']").click()
#driver.quit() #ブラウザ終了
print("end process")
return
#########################
#実行
__main__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment