GET和POST方式請求API介面資料返回

chatGPT發表於2023-04-14

GET在瀏覽器回退時是無害的,而POST會再次提交請求。

GET產生的URL地址可以被Bookmark,而POST不可以。

GET請求會被瀏覽器主動cache,而POST不會,除非手動設定。

GET請求只能進行url編碼,而POST支援多種編碼方式。

GET請求引數會被完整保留在瀏覽器歷史記錄裡,而POST中的引數不會被保留。

GET請求在URL中傳送的引數是有長度限制的,而POST麼有。

對引數的資料型別,GET只接受ASCII字元,而POST沒有限制。

GET比POST更不安全,因為引數直接暴露在URL上,所以不能用來傳遞敏感資訊。

GET引數透過URL傳遞,POST放在Request body中。

特別:

GET和POST還有一個重大區別,簡單的說:

GET產生一個TCP資料包;POST產生兩個TCP資料包。

長的說:

對於GET方式的請求,瀏覽器會把http header和data一併傳送出去,伺服器響應200(返回資料);

而對於POST,瀏覽器先傳送header,伺服器響應100 continue,瀏覽器再傳送data,伺服器響應200 ok(返回資料)。

但是:

1. GET與POST都有自己的語義,不能隨便混用。

2. 據研究,在網路環境好的情況下,發一次包的時間和發兩次包的時間差別基本可以無視。而在網路環境差的情況下,兩次包的TCP在驗證資料包完整性上,有非常大的優點。

3. 並不是所有瀏覽器都會在POST中傳送兩次包,Firefox就只傳送一次。


返回的資料是一樣的,如下所示

{
    "item": {
        "num_iid": "652874751412",
        "title": "北歐輕奢布藝沙發 小戶型簡約現代客廳ins風網紅款三雙人訂製沙發",
        "desc_short": "",
        "price": "480.00",
        "total_price": 0,
        "suggestive_price": 0,
        "orginal_price": "3400.00",
        "nick": "惜情yqq1127",
        "num": 1550,
        "min_num": 0,
        "detail_url": "
        "pic_url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg",
        "brand": "#0 工廠",
        "brandId": null,
        "rootCatId": "50008164",
        "cid": "50020632",
        "crumbs": [],
        "created_time": "",
        "modified_time": "",
        "delist_time": "",
        "desc": "<div > \n   <div >\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n    <img src=\"!!2568161054.jpg\"  />\n   </div> \n  </div><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-4.6438c7992c849&p=1778786741&k=i_key&t=1681442715\" style=\"display:none\" />",
        "desc_img": [
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg",
            "!!2568161054.jpg"
        ],
        "item_imgs": [
            {
                "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg"
            },
            {
                "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01kjOfNb1Jem9DmWn8Y_!!2568161054.jpg"
            },
            {
                "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN01HoB9ha1Jem9DmWn8r_!!2568161054.jpg"
            },
            {
                "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN011PjP2P1Jem9MXEUFT_!!2568161054.jpg"
            },
            {
                "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01KUfBFL1Jem9KTTMn1_!!2568161054.jpg"
            }
        ],
        "item_weight": "",
        "item_size": "",
        "location": "江蘇南通",
        "post_fee": "",
        "express_fee": null,
        "ems_fee": "",
        "shipping_to": "",
        "has_discount": "true",
        "video": {
            "url": null
        },
        "is_virtual": "",
        "sample_id": "",
        "is_promotion": "true",
        "props_name": "31480:14306495906:幾人坐:腳踏90*60*48cm;31480:14306495907:幾人坐:雙人165*95*67cm;31480:14306495908:幾人坐:三人210*95*67cm;31480:14306495909:幾人坐:單人100*95*67cm;31480:21480914361:幾人坐:四人位240*95*67cm;31480:21480914362:幾人坐:大四人320*95*76cm;31480:1387571900:幾人坐:3米貴妃沙發;31480:32527954:幾人坐:定製尺寸;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
        "prop_imgs": {
            "prop_img": [
                {
                    "properties": "1627207:28321",
                    "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
                }
            ]
        },
        "property_alias": "",
        "props": [
            {
                "name": "品牌",
                "value": "#0 工廠"
            },
            {
                "name": "型號",
                "value": "520"
            },
            {
                "name": "材質",
                "value": "木"
            },
            {
                "name": "木質材質",
                "value": "松木"
            },
            {
                "name": "面料",
                "value": "絨布"
            },
            {
                "name": "風格",
                "value": "北歐"
            },
            {
                "name": "幾人坐",
                "value": "腳踏90*60*48cm,雙人165*95*67cm,三人210*95*67cm,單人100*95*67cm,四人位240*95*67cm,大四人320*95*76cm,3米貴妃沙發,定製尺寸"
            },
            {
                "name": "顏色分類",
                "value": "乳白色"
            },
            {
                "name": "填充物",
                "value": "海綿"
            },
            {
                "name": "結構工藝",
                "value": "木質工藝"
            },
            {
                "name": "是否可定製",
                "value": "是"
            },
            {
                "name": "沙發組合形式",
                "value": "U形"
            },
            {
                "name": "是否可拆洗",
                "value": "是"
            },
            {
                "name": "適用物件",
                "value": "成年人"
            },
            {
                "name": "是否帶儲物空間",
                "value": "否"
            },
            {
                "name": "產地",
                "value": "上海"
            },
            {
                "name": "地市",
                "value": "上海市"
            },
            {
                "name": "區縣",
                "value": "奉賢區"
            },
            {
                "name": "是否組裝",
                "value": "否"
            },
            {
                "name": "計程車是否可運輸",
                "value": "否"
            },
            {
                "name": "填充物硬度",
                "value": "軟"
            },
            {
                "name": "款式定位",
                "value": "經濟型"
            }
        ],
        "total_sold": null,
        "skus": {
            "sku": [
                {
                    "price": "480",
                    "total_price": 0,
                    "orginal_price": "480",
                    "properties": "31480:14306495906;1627207:28321",
                    "properties_name": "31480:14306495906:幾人坐:腳踏90*60*48cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "4881047531343"
                },
                {
                    "price": "1688",
                    "total_price": 0,
                    "orginal_price": "1688",
                    "properties": "31480:14306495907;1627207:28321",
                    "properties_name": "31480:14306495907:幾人坐:雙人165*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "150",
                    "sku_id": "4881047531344"
                },
                {
                    "price": "2088",
                    "total_price": 0,
                    "orginal_price": "2088",
                    "properties": "31480:14306495908;1627207:28321",
                    "properties_name": "31480:14306495908:幾人坐:三人210*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "4881047531345"
                },
                {
                    "price": "968",
                    "total_price": 0,
                    "orginal_price": "968",
                    "properties": "31480:14306495909;1627207:28321",
                    "properties_name": "31480:14306495909:幾人坐:單人100*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "4881047531346"
                },
                {
                    "price": "2388",
                    "total_price": 0,
                    "orginal_price": "2388",
                    "properties": "31480:21480914361;1627207:28321",
                    "properties_name": "31480:21480914361:幾人坐:四人位240*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "5039985183001"
                },
                {
                    "price": "3188",
                    "total_price": 0,
                    "orginal_price": "3188",
                    "properties": "31480:21480914362;1627207:28321",
                    "properties_name": "31480:21480914362:幾人坐:大四人320*95*76cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "5039985183002"
                },
                {
                    "price": "3400",
                    "total_price": 0,
                    "orginal_price": "3400",
                    "properties": "31480:1387571900;1627207:28321",
                    "properties_name": "31480:1387571900:幾人坐:3米貴妃沙發;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "5039984824000"
                },
                {
                    "price": "3000",
                    "total_price": 0,
                    "orginal_price": "3000",
                    "properties": "31480:32527954;1627207:28321",
                    "properties_name": "31480:32527954:幾人坐:定製尺寸;1627207:28321:顏色分類:乳白色 尺寸顏色可定製",
                    "quantity": "200",
                    "sku_id": "5039985183003"
                }
            ]
        },
        "seller_id": "2568161054",
        "sales": 35,
        "shop_id": "567158267",
        "props_list": {
            "31480:14306495906": "幾人坐:腳踏90*60*48cm",
            "31480:14306495907": "幾人坐:雙人165*95*67cm",
            "31480:14306495908": "幾人坐:三人210*95*67cm",
            "31480:14306495909": "幾人坐:單人100*95*67cm",
            "31480:21480914361": "幾人坐:四人位240*95*67cm",
            "31480:21480914362": "幾人坐:大四人320*95*76cm",
            "31480:1387571900": "幾人坐:3米貴妃沙發",
            "31480:32527954": "幾人坐:定製尺寸",
            "1627207:28321": "顏色分類:乳白色 尺寸顏色可定製"
        },
        "seller_info": {
            "nick": "惜情yqq1127",
            "item_score": "4.9 ",
            "score_p": "4.9 ",
            "delivery_score": "4.9 ",
            "shop_type": "C",
            "user_num_id": "2568161054",
            "sid": "567158267",
            "title": "現代布藝沙發",
            "zhuy": "
            "shop_name": "現代布藝沙發"
        },
        "tmall": false,
        "error": "",
        "warning": "",
        "url_log": [],
        "fav_count": "7436",
        "fans_count": "644",
        "freight": "平郵: 快遞包郵",
        "props_imgs": {
            "prop_img": [
                {
                    "properties": "1627207:28321",
                    "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
                }
            ]
        },
        "_ddf": "fu",
        "promo_type": null,
        "props_img": {
            "1627207:28321": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg"
        },
        "format_check": "ok",
        "shop_item": [],
        "relate_items": []
    },
    "error": "",
    "secache": "4ad7ad2480af253fec9c2fd4daa266bb",
    "secache_time": 1681442715,
    "secache_date": "2023-04-14 11:25:15",
    "translate_status": "",
    "translate_time": 0,
    "language": {
        "default_lang": "cn",
        "current_lang": "cn"
    },
    "reason": "",
    "error_code": "0000",
    "cache": 0,
    "api_info": "today:30 max:10100 all[69=30+21+18];expires:2030-12-31",
    "execution_time": "1.872",
    "server_time": "Beijing/2023-04-14 11:25:15",
    "client_ip": "106.6.33.181",
    "call_args": {
        "num_iid": "652874751412",
        "is_promotion": "1"
    },
    "api_type": "taobao",
    "translate_language": "zh-CN",
    "translate_engine": "baidu",
    "server_memory": "0.94MB",
    "request_id": "gw-4.6438c7992c849",
    "last_id": "1677743647"
}

展示效果


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70026630/viewspace-2945747/,如需轉載,請註明出處,否則將追究法律責任。

相關文章