CURL 到网站 API 响应不同的结果

问题描述

正如标题所说,我使用 firefox network explorer 来使用 API,我已经成功地复制了几样这样的东西,但这一次给出了不同的结果

因此,在网络中,查询是对 https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL 的 GET,响应是有效的 JSON(至少 Firefox 和 Chrome 都显示了这一点)

{"code":"000000","message":"null","messageDetail":null,"data":[{"asset":"USDT","list":[{"projectId":"CUSDT7DAYS001","projectName":"USDT","lotsuplimit":"2000000","lotsLowLimit":"1","lotsPurchased":"224565","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDT","interestRate":"0.06310000","interestPerLot":"0.12090000","duration":"7","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"1"},{"projectId":"CUSDT14DAYSS001","lotsPurchased":"190167","interestRate":"0.06480000","interestPerLot":"0.24860000","duration":"14",{"projectId":"CUSDT30daySS001","lotsPurchased":"676977","interestRate":"0.06660000","interestPerLot":"0.54720000","duration":"30",{"projectId":"CUSDT90daySS001","lotsPurchased":"969489","interestRate":"0.07000000","interestPerLot":"1.72700000","duration":"90","displayPriority":"1"}]},{"asset":"BUSD","list":[{"projectId":"CBUSD7DAYS001","projectName":"BUSD","lotsuplimit":"500000","lotsPurchased":"30744","maxLotsPerUser":"100000","asset":"BUSD","displayPriority":"2"},{"projectId":"CBUSD14DAYSS001","lotsPurchased":"20988",{"projectId":"CBUSD30daySS001","lotsPurchased":"151414",{"projectId":"CBUSD90daySS001","lotsPurchased":"204698","displayPriority":"2"}]},{"asset":"USDC","list":[{"projectId":"USDC7DAYSS001","projectName":"USDC","lotsPurchased":"26688","asset":"USDC","interestRate":"0.05310000","interestPerLot":"0.10180000","displayPriority":"3"},{"projectId":"USDC14DAYSS001","lotsPurchased":"19296","interestRate":"0.05480000","interestPerLot":"0.21010000",{"projectId":"USDC30daySS001","lotsPurchased":"20059","interestRate":"0.05660000","interestPerLot":"0.46520000",{"projectId":"USDC90daySS001","lotsPurchased":"94209","interestRate":"0.06000000","interestPerLot":"1.47940000","displayPriority":"3"}]}],"total":3,"success":true}

但是,当我尝试在同一个网站上使用 curl 时,它会抛出一个通用的网络错误

curl https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL 
HTTP/1.1 404 Not Found
Content-Type: text/html
transfer-encoding: chunked
Connection: keep-alive
Date: Tue,09 Feb 2021 21:19:48 GMT
Server: Tengine
vary: Accept-Encoding
ETag: W/"5ff3db87-197a"
x-frame-options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: origin-when-cross-origin
Strict-Transport-Security: max-age=31536000; includeSubdomains
content-encoding: gzip
X-Cache: Error from cloudfront
Via: 1.1 da12738b8eacc0d543b2915c5e4262dd.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: SYD1-C2
X-Amz-Cf-Id: xS7LR0Qvm4onqjXxgaA7IG6LPrYNk3VJ0hFV0wFvk2Vk7oPTrRk8jw==

加载这个api的站点https://www.binance.com/en/earn#fixed-item

这是一些截图

enter image description here

enter image description here

解决方法

我设法在 curl curl -XGET -H "Content-type: application/json" 'https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL'

中使用了一些额外的东西