gpt4 book ai didi

python - 从 Selenium 中的 url 下载 CSV?

转载 作者:太空宇宙 更新时间:2023-11-03 11:30:22 24 4
gpt4 key购买 nike

我有一个 URL,我想从中定期下载。它只能从需要 javascript 支持的登录帐户访问,所以我被迫将 Selenium 与 PhantomJS 一起使用,相信我。否则,我会为此使用 urllib,但它给我一个登录错误。

这是一个 CSV 文件,最多 1000 行,大约 6 列。

我想最终将此 CSV 放入列表中。有谁知道如何使用 Selenium Webdriver 下载 CSV 文件?

非常感谢。

编辑:我只是想从 Selenium 中的 URL 下载 CSV。没有别的。

最佳答案

其实很简单。使用我在 stack over flow 中给出的另一个答案

https://stackoverflow.com/a/21871600/2423379

编辑:在 Headless 模式下运行 Firefox

要求:

  • sudo apt-get install xvfb(或您的发行版中的等效命令)
  • pip install --user xvfbwrapper

和代码部分

from xvfbwrapper import Xvfb

vdisplay = Xvfb()
vdisplay.start()

# launch stuff inside virtual display here

vdisplay.stop()

引用:Firefox-selenium in headless mode

关于python - 从 Selenium 中的 url 下载 CSV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21864530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com