通过批量自定义标题下载文件 [英] Download files via batch with custom header

查看:175
本文介绍了通过批量自定义标题下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从opentripplanner服务器下载大量的isochronics。
限制是:没有可能的外部工具或安​​装。客户端是Windows 7.要创建.bat文件,我使用自制的Excel工具。



默认响应是.json文件格式。这适用于bitsadmin:

  bitsadmin / Transfer Download_Isochrone_1 / download / priority normal http://exampleserver.com/otp- ?其余-的servlet / WS /等时路由器ID =波尔多^&安培;算法= accSampling ^&安培; fromPlace = 47.059,-0.880 ^&安培;日期=十分之二千零一十三/ 01 ^&安培;时间= 12:00:00 ^&安培; maxWalkDistance = 1000 ^& mode = WALK,TRANSIT ^& cutoffSec = 1800 ^& cutoffSec = 3600 c:\ username \downloads\Isochrone_1.json 
bitsadmin / Transfer Download_Isochrone_2 / download / priority normal http: //exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.089,-0.881^&date=2013/10/01^&time=12 :00:00 ^& maxWalkDistance = 1000 ^& mode = WALK,TRANSIT& cutoffSec = 1800 ^& cutoffSec = 3600 c:\username\downloads\Isochrone_2.json
bitsadmin / Transfer Download_Isochrone_3 /下载/优先级正常http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling ^&安培; fromPlace = 47.159,-0.882 ^&安培;日期= 2013年/ 10/01 ^&安培;时间= 12:00:00 ^&安培; maxWalkDistance = 1000 ^&安培;模式= WALK,TRANSIT ^&安培; cutoffSec = 1800 ^ & cutoffSec = 3600 c:\username\downloads\Ichchrone_3.json

但.shp (.zip)可以通过使用自定义标题。 (Accept:application / x-zip-compressed)。已经通过Browser-Plugin完成了一个等时线。
所以我试过了
$ b $ pre $ bitsadmin /创建/下载Download_Isochrones
bitsadmin / SetCustomHeader Download_IsochronesAccept:application / x-zip-compressed
bitsadmin / Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.059,-0.880 ^& date = 2013/10/01 ^& time = 12:00:00 ^& maxWalkDistance = 1000 ^& mode = WALK,TRANSIT ^&cutoffSec = 1800 ^& cutoffSec = 3600 c:\ username \downloads\Ichchrone_1.txt
bitsadmin / Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.089 ,-0.881& date = 2013/10/01 ^& time = 12:00:00 ^& maxWalkDistance = 1000 ^& mode = WALK,TRANSIT& cutoffSec = 1800 ^& cutoffSec = 3600 c:\\ \\ username \downloads\Ichchrone_2.txt
bitsadmin / Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=b ordeaux ^&安培;算法= accSampling ^&安培; fromPlace = 47.159,-0.882 ^&安培;日期= 2013年/ 10/01 ^&安培;时间= 12:00:00 ^&安培; maxWalkDistance = 1000 ^&安培;模式= WALK,TRANSIT ^& cutoffSec = 1800 ^& cutoffSec = 3600 c:\username\downloads\Isochrone_3.txt
bitsadmin / Resume Download_Isochrones
bitsadmin / Complete Download_Isochrones

但它不起作用。实际上,/ Addfile似乎根本无法用于此目的。 (使用.txt扩展名进行测试)
是否可以通过/ setcustomheader合并/传输?或者我只是在上面的代码中犯了错误?还是有没有其他的可能性来做到这一点没有win7的外部工具?
如果有兴趣,请继续阅读OpenTripPlanner文档: http:// dev.opentripplanner.org/apidoc/1.0.0/resource_LIsochrone.html

解决方案

使用 winhttpjs.bat

 调用winhttpjs.bathttps://requestb.in/vp4p0gvp-headers-file headers.txt -saveTo file.gzip 

您需要在同一目录中显示headers.txt文件,如下所示:

  #compression header 
接受:application / x-zip-compressed

要检查结果,我在上创建了一个测试链接 href =https://requestb.in =nofollow noreferrer> https://requestb.in 坐e。

Im trying to download tons of isochrones from an opentripplanner server. Restriction is: no external tools or installations possible. Client is Windows 7. To create the .bat file i use a selfmade excel tool.

Default response is .json file format. This works just fine with bitsadmin:

bitsadmin /Transfer Download_Isochrone_1 /download /priority normal http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.059,-0.880^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT^&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_1.json
bitsadmin /Transfer Download_Isochrone_2 /download /priority normal http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.089,-0.881^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_2.json
bitsadmin /Transfer Download_Isochrone_3 /download /priority normal http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.159,-0.882^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT^&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_3.json

But .shp (.zip) is possible by using a custom header. ("Accept: application/x-zip-compressed"). Already done this via Browser-Plugin for a single isochrone. So i tried

bitsadmin /Create /Download Download_Isochrones
bitsadmin /SetCustomHeader Download_Isochrones "Accept: application/x-zip-compressed"
bitsadmin /Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.059,-0.880^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT^&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_1.txt
bitsadmin /Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.089,-0.881^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_2.txt
bitsadmin /Addfile Download_Isochrones http://exampleserver.com/otp-rest-servlet/ws/isochrone?routerId=bordeaux^&algorithm=accSampling^&fromPlace=47.159,-0.882^&date=2013/10/01^&time=12:00:00^&maxWalkDistance=1000^&mode=WALK,TRANSIT^&cutoffSec=1800^&cutoffSec=3600 c:\username\downloads\Isochrone_3.txt
bitsadmin /Resume Download_Isochrones
bitsadmin /Complete Download_Isochrones

But it doesnt work. Actually "/Addfile" seems to not work at all for this purpose. (using .txt extension for testing purposes) Is it somehow possible to to combine /transfer with /setcustomheader or did i just do a mistake in the code above? Or is there any other possibilty to do this without win7-external tools? In case of interest, heres the OpenTripPlanner doc: http://dev.opentripplanner.org/apidoc/1.0.0/resource_LIsochrone.html

解决方案

Try with winhttpjs.bat:

call winhttpjs.bat "https://requestb.in/vp4p0gvp"  -headers-file headers.txt  -saveTo file.gzip

You'll need a headers.txt file in the same directory looking like:

#compression header
Accept: application/x-zip-compressed

To check the result I've created a a test link on the https://requestb.in site.

这篇关于通过批量自定义标题下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆