Last active
March 17, 2016 11:24
-
-
Save kurozumi/e738fe540591673c58af to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってCSVファイルをダウンロードする方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
from selenium import webdriver | |
fp = webdriver.FirefoxProfile() | |
# 0:デスクトップ、1:システム規定のフォルファ、2:ユーザ定義フォルダ | |
fp.set_preference("browser.download.folderList",2) | |
# 上記で2を選択したのでファイルのダウンロード場所を指定 | |
fp.set_preference("browser.download.dir", os.getcwd()) | |
# ダウンロード完了時にダウンロードマネージャウィンドウを表示するかどうかを示す真偽値。 | |
fp.set_preference("browser.download.manager.showWhenStarting",False) | |
# mimeタイプを設定 | |
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream") | |
driver = webdriver.Firefox(firefox_profile=fp) | |
driver.get("http://www.japannetbank.co.jp/service/payment/web_all/csv_download.html") | |
driver.find_element_by_partial_link_text(u"全銀形式").click() | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment