2017-07-03 50 views
1

我有一個非常簡單的郵遞員請求,在郵遞員中工作得很好。這只是一個GET請求到以下網址:請求郵遞員的作品,但不是cURL

http://www.toysrus.com/storefrontsearch/stores.jsp?skuId=24654884&quantity=1&postalCode=48103&latitude&longitude&productId=107531766&startIndexForPagination=0&searchRadius=0&pageType=product&ispu_or_sts=null&displayAllStoresFlag=false&displayAllStoreLink=false

如果我問郵差,使捲曲的要求進行的,對我來說,它給了我這樣的:

curl -X GET \ 'http://www.toysrus.com/storefrontsearch/stores.jsp?skuId=24654884&quantity=1&postalCode=48103&latitude=&longitude=&productId=107531766&startIndexForPagination=0&searchRadius=0&pageType=product&ispu_or_sts=null&displayAllStoresFlag=false&displayAllStoreLink=false' \ -H 'cache-control: no-cache' \ -H 'postman-token: b4ae79c0-c3f0-8247-8c2f-306c43376039'

結果是它永遠掛起,永遠不會給我一個迴應。

任何想法可以做些什麼來讓cURL請求工作?

+0

更新:我發現了一個GET請求將在郵差,工作得很好,其我相信稍微簡化了這個問題。 –

+0

然後從捲曲線中刪除'-X GET' ... –

+0

就像我說的,我的'curl'命令剛剛從郵差中直接出來。我推斷,無論'-X GET'是否存在,命令在功能上都是等效的,因此刪除它不會改變任何內容。 (我嘗試了不帶'-X GET'的命令,只是爲了確保我沒有發瘋,並且請求似乎以相同的方式失敗。) –

回答

2

看來服務器已經禁止捲曲用戶代理,也troute=t1需要cookies來另行設置返回404:

curl -L -H 'User-Agent: Mozilla' \ 
     -H 'Cookie: troute=t1;' \ 
     'http://www.toysrus.com/storefrontsearch/stores.jsp?skuId=24654884&quantity=1&postalCode=48103&latitude&longitude&productId=107531766&startIndexForPagination=0&searchRadius=0&pageType=product&ispu_or_sts=null&displayAllStoresFlag=false&displayAllStoreLink=false' --compressed 
+0

這似乎是票。謝謝! –

相關問題