CSV从网站下载到R中,可以访问直接链接

时间:2019-01-08 13:33:53

标签: javascript php html r csv

我正在尝试编写一个R脚本,该脚本允许我自动下载具有可变开始和结束日期的csv文件。我想创建一个闪亮的应用程序,例如从上个月从一些网站下载数据。对于大多数网站来说,这很简单:

-访问网站代码

-查找他们正在使用的链接结构(www.example.com/download/csv/startdate_enddate或类似的东西)

-在我的代码中使用该链接,并将“开始日期”和“结束日期”定义为可由用户输入修改的变量。

到目前为止,还算不错,但是现在我有一个特定的网站,在该网站上我找不到链接的哪个部分负责定义日期范围,而且它们也使用井号。我可以提取的唯一链接看起来像这样:

[https://www.tennet.eu/de/strommarkt/transparenz/transparenz-deutschland/netzkennzahlen/tatsaechliche-und-prognostizierte-windenergieeinspeisung/?tx_tennetcw_transparency%5Baction%5D=csvDownload&tx_tennetcw_transparency%5Bcontroller%5D=Transparency&cHash=4319b4da8058a55eafddb1778fc3c605][2]

当我尝试打开链接时,它会产生错误,而不是所需的csv下载。我已经打印了我认为在下面很重要的部分代码。我真的无法理解。也许你们可以之一?

<div id="c17801" class="transparency">

        <form method="post" id="dateForm" action="https://www.tennet.eu/de/strommarkt/transparenz/transparenz-deutschland/netzkennzahlen/tatsaechliche-und-prognostizierte-windenergieeinspeisung/?tx_tennetcw_transparency%5Bcontroller%5D=Transparency&amp;cHash=0c5a69f0d1ca095dbb24b00305db7493">
<div>
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@extension]" value="TennetCw">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@vendor]" value="Arvato">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@controller]" value="Transparency">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@action]" value="list">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][arguments]" value="YTowOnt96b882eafe83827345698c053f8021fe553f44326">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@request]" value="a:4:{s:10:&quot;@extension&quot;;s:8:&quot;TennetCw&quot;;s:11:&quot;@controller&quot;;s:12:&quot;Transparency&quot;;s:7:&quot;@action&quot;;s:4:&quot;list&quot;;s:7:&quot;@vendor&quot;;s:6:&quot;Arvato&quot;;}8f91dd11199b4d706eaa7939dfa04d22d7122893">
<input type="hidden" name="tx_tennetcw_transparency[__trustedProperties]" value="a:5:{s:9:&quot;daterange&quot;;i:1;s:5:&quot;sDate&quot;;i:1;s:5:&quot;eDate&quot;;i:1;s:7:&quot;current&quot;;i:1;s:5:&quot;email&quot;;i:1;}7bd71ac7c27524cfeea0fd8eb75b19db669075ab">
</div>

            <input id="daterange" type="text" name="tx_tennetcw_transparency[daterange]">
            <span class="icon-calendar"></span>
            <span class="input-group-addon btn">
                <a title="CSV Download"><span class="icon-download"></span></a>
            </span>
            <span class="input-group-addon btn">
                <span title="PNG Download" id="chartToImg"><span class="icon-image"></span></span>
            </span>
            <input id="sDate" type="hidden" name="tx_tennetcw_transparency[sDate]" value="">
            <input id="eDate" type="hidden" name="tx_tennetcw_transparency[eDate]" value="">
            <input id="current" type="hidden" name="tx_tennetcw_transparency[current]" value="windPowerFeedIn">
            <input class="email" type="email" name="tx_tennetcw_transparency[email]" value="">
        </form>

        <form method="post" id="csvForm" action="https://www.tennet.eu/de/strommarkt/transparenz/transparenz-deutschland/netzkennzahlen/tatsaechliche-und-prognostizierte-windenergieeinspeisung/?tx_tennetcw_transparency%5Baction%5D=csvDownload&amp;tx_tennetcw_transparency%5Bcontroller%5D=Transparency&amp;cHash=4319b4da8058a55eafddb1778fc3c605">
<div>
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@extension]" value="TennetCw">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@vendor]" value="Arvato">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@controller]" value="Transparency">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@action]" value="list">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][arguments]" value="YTowOnt96b882eafe83827345698c053f8021fe553f44326">
<input type="hidden" name="tx_tennetcw_transparency[__referrer][@request]" value="a:4:{s:10:&quot;@extension&quot;;s:8:&quot;TennetCw&quot;;s:11:&quot;@controller&quot;;s:12:&quot;Transparency&quot;;s:7:&quot;@action&quot;;s:4:&quot;list&quot;;s:7:&quot;@vendor&quot;;s:6:&quot;Arvato&quot;;}8f91dd11199b4d706eaa7939dfa04d22d7122893">
<input type="hidden" name="tx_tennetcw_transparency[__trustedProperties]" value="a:5:{s:7:&quot;current&quot;;i:1;s:3:&quot;uid&quot;;i:1;s:5:&quot;sDate&quot;;i:1;s:5:&quot;eDate&quot;;i:1;s:5:&quot;email&quot;;i:1;}172537dd2ccfc75d9cd1f075558d525c95ff58e2">
</div
            <input type="hidden" name="tx_tennetcw_transparency[current]" value="windPowerFeedIn">
            <input type="hidden" name="tx_tennetcw_transparency[uid]" value="17801">
            <input id="sDateCsv" type="hidden" name="tx_tennetcw_transparency[sDate]" value="2019-01-07">
            <input id="eDateCsv" type="hidden" name="tx_tennetcw_transparency[eDate]" value="2019-01-07">
            <input type="hidden" name="type" value="7788">
            <input class="email" type="email" name="tx_tennetcw_transparency[email]" value="">
</div>

在我看来,日期为值的变量“ tx_tennetcw_transparency [sDate]”在这里很关键。但是我坚持尝试修改链接,以便它完全下载任何csv ... 抱歉,如果这个问题对任何人都很愚蠢,则不是编程专家:/

请帮助!

干杯! YS

0 个答案:

没有答案