gpt4 book ai didi

javascript - CasperJS - 下载没有 URL 的生成文件

转载 作者:可可西里 更新时间:2023-11-01 02:27:47 24 4
gpt4 key购买 nike

我已经为此苦苦挣扎了一段时间。

我正在尝试下载由 Google Adwords“下载报告”按钮生成的 CSV 文件。我可以很好地单击链接并在后台查看资源。问题是为了下载它,casperJS/phantomJS 需要文件的 URL...主页,而不是 CSV 文件,因此 casperJS 无法下载它)。

有没有办法在没有 URL 的情况下保存该资源?

我找到了这个解决方法:downloading a file that comes as an attachment in a POST request response in PhantomJs

但不幸的是,Google Adwords 报告按钮没有可供我引用的表格。

最佳答案

我用 chrome 开发者工具做了一个简单的请求分析:下载请求(对我而言)转到以下 URL:

Request URL:https://adwords.google.com/reports/advanced/ReportDownload?authuser=0

表单数据:

__rds:{{censored}}
__rrd:{{censored}}
__u:{{censored}}
__c:{{censored}}
__rfl:8,9,10
token:{{censored}}:{{censored}}

请求 header :

:authority:adwords.google.com
:method:POST
:path:/reports/advanced/ReportDownload?authuser=0
:scheme:https
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/ *;q=0.8
accept-encoding:gzip, deflate
accept-language:en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4,hr;q=0.2,sr;q=0.2
cache-control:max-age=0
content-length:501
content-type:application/x-www-form-urlencoded
cookie: {{censored}}
dnt:1
origin:https://adwords.google.com
referer:https://adwords.google.com/reports/advanced/AdvancedReporting?__c={{censored}}&__u={{censored}}&authuser=0&__o=cues
upgrade-insecure-requests:1
user-agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
x-client-data:{{censored}}

我已通过将其替换为 {{censored}} 标签来删除可能特定于我的数据。

关于javascript - CasperJS - 下载没有 URL 的生成文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28703574/

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