簡體   English   中英

卷曲請求與瀏覽器不同

[英]Curl request different from browser

我試圖從ESA訪問API。 詳情點擊這里使用curl時,

curl -svgu <user>:<password> "https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10"

被告人的日期有誤(2014)

在chrome上使用相同的鏈接,可以產生預期的結果(帶有日期的文件)

https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10

我試圖刪除空間並使用

`"https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate)%20eq%202015%20and%20month(IngestionDate)%20eq%2010%20and%20day(IngestionDate)%20eq%2010"`

卷曲。

有什么建議或想法嗎? 您可以使用這些鏈接進行嘗試。

編輯:根據Pafjo的建議,curl -G -gu:“ https://scihub.esa.int/dhus/odata/v1/Products ” --data-urlencode'$ filter = year(IngestionDate)eq'“ $ YEAR和month(IngestionDate)eq $ MONTH和day(IngestionDate)eq $ DAY”這就是答案

Curl不會對您的網址進行url編碼,因此您需要告訴它應該對url進行編碼的部分。

嘗試此操作,看看您的響應是否正確:

curl -G -svgu  <user>:<password> "https://scihub.esa.int/dhus/odata/v1/Products" --data-urlencode '$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10'

您的第二個curl命令失敗的原因是您在雙引號中包含了$ filter。 因此,當您執行請求時,shell會將變量替換為值。 通過使用單引號或轉義美元符號可以解決此問題。

  1. 可以使用您正在使用的shell解釋Curl參數。 在這種情況下,您可能需要轉義正則表達式字符(和)。
  2. URL中不允許使用空格。 您可能應該將它們替換為%20。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM