【问题标题】:Trigger a websites file download with python使用 python 触发网站文件下载
【发布时间】:2013-09-03 14:37:48
【问题描述】:

有一个名为finviz的股票筛选网站。您可以为其设置特定参数进行筛选,然后在右下角有一个按钮可以让您将结果导出为 .cvs 文件。

我想在 python 2.7 中创建一个脚本,用于下载和分析文件。我想我可以使用 urllib2 访问该网站,但是如何触发导出,然后从该结果文件中读取?使用标准的 urllib2.urlopen(url).read(),返回整个站点的 html 文件,而不是我需要的导出。

【问题讨论】:

    标签: python csv python-2.7 urllib2


    【解决方案1】:

    事实证明,至少在这种情况下,导出按钮实际上是指向不同 url 的链接。那么筛选器的网址可能在哪里:http://finviz.com/screener.ashx?v=111&f=sh_price_u1。 url 的导出版本为:http://finviz.com/export.ashx?v=111&f=sh_price_u1。 第二个 url 具有触发下载的功能,所以我需要代替 urllib2.urlopen("http://finviz.com/screener.ashx?v=111&f=sh_price_u1").read() urllib2.urlopen("http://finviz.com/export.ashx?v=111&f=sh_price_u1").read()

    【讨论】:

      【解决方案2】:

      这个是在 python 中完成的。看一看。 https://github.com/nicolamr/trending-value

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        • 2019-05-09
        • 1970-01-01
        • 2016-02-04
        • 2021-12-01
        • 2019-07-04
        相关资源
        最近更新 更多