使用 PhantomJS 自动下载 blob URL

Automate blob URL download with PhantomJS

我正在尝试通过使用 PhantomJS 单击网站上的对象来自动下载 CSV 文件。

function() {
    (page.evaluate(function() {
        $("export2csv").click();
    }))
}

如果我 运行 在 Chrome 开发控制台中开始下载 CSV 文件。
Chrome 显示 blob:https://website/seeminglyrandomstring 作为它的来源,这意味着我没有静态 URL 指向这个文件。

如果我在 PhantomJS 中 运行 但是,没有输出,就像它完成时没有任何错误一样。但我也没有得到我的文件。 这与官方文档中的以下说法有关系吗?

The execution is sandboxed, the web page has no access to the phantom object and it can’t probe its own setting.

我在 Windows

上使用 PhantomJS 2.0.0

由于 PhantomJS 的限制,我将在 Windows 上尝试将 Chromedriver 与 Selenium 一起用于 Python。

编辑:

这是一个简单的解决方案:

import time
from selenium import webdriver

#xenoid 18.01.2018


#Starting the driver
chromeOptions = webdriver.ChromeOptions()

#Download directory
prefs = {"download.default_directory" : "C:/temp/"}
chromeOptions.add_experimental_option("prefs",prefs)
#Location to chromedriver
driver = webdriver.Chrome('C:\chromedriver\chromedriver.exe', 
chrome_options=chromeOptions)
driver.get("_URL_TO_WEBSITE_");
#Time it takes for the website to load
time.sleep(5)
#Click the button
button = driver.find_element_by_css_selector("_YOUR_CSS_SELECTOR_'")
button.click()
time.sleep(3)
driver.quit()