• 【Python爬虫】网页抓取实例之淘宝商品信息抓取


    之前我们已经说过网页抓取的相关内容

    上次我们是以亚马逊某网页的产品为例

    抓取价格、品牌、型号、样式等

    图片

    该网页上价格、品牌、型号、样式等

    都只有一个

    如果网页上的目标内容

    根据不同规格有多个

    又该怎么提取呢?

    ▼如下图所示

    当机身颜色、套餐、存储容量等

    规格不同时

    对应价格也不同

    那该怎么获取不同属性下的价格呢?

     此时需要用到抓取商品详情信息的API接口item_get、或者item_get_sku。

    详细调用步骤如下:

    1、获取API调用权限,注册key和密钥

    2、进入API测试页,输入商品id,调用API。如下图:

    3、找到响应示例中的sku信息

    1. "skus": {
    2. "sku": [
    3. {
    4. "price": 678,
    5. "total_price": 0,
    6. "orginal_price": 678,
    7. "properties": "1627207:1007902496;5919063:6536025;12304035:1905146457",
    8. "properties_name": "1627207:1007902496:机身颜色:幻夜黑;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1905146457:存储容量:6+128GB",
    9. "quantity": 200,
    10. "sku_id": "5142540523707"
    11. },
    12. {
    13. "price": 778,
    14. "total_price": 0,
    15. "orginal_price": 778,
    16. "properties": "1627207:1007902496;5919063:6536025;12304035:1963543205",
    17. "properties_name": "1627207:1007902496:机身颜色:幻夜黑;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1963543205:存储容量:8+128GB",
    18. "quantity": 200,
    19. "sku_id": "5142540523708"
    20. },
    21. {
    22. "price": 868,
    23. "total_price": 0,
    24. "orginal_price": 868,
    25. "properties": "1627207:1007902496;5919063:3266779;12304035:1905146457",
    26. "properties_name": "1627207:1007902496:机身颜色:幻夜黑;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1905146457:存储容量:6+128GB",
    27. "quantity": 0,
    28. "sku_id": "5141622086982"
    29. },
    30. {
    31. "price": 878,
    32. "total_price": 0,
    33. "orginal_price": 878,
    34. "properties": "1627207:1007902496;5919063:3266779;12304035:1963543205",
    35. "properties_name": "1627207:1007902496:机身颜色:幻夜黑;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1963543205:存储容量:8+128GB",
    36. "quantity": 200,
    37. "sku_id": "5141622086983"
    38. },
    39. {
    40. "price": 678,
    41. "total_price": 0,
    42. "orginal_price": 678,
    43. "properties": "1627207:2771458827;5919063:6536025;12304035:1905146457",
    44. "properties_name": "1627207:2771458827:机身颜色:苏音蓝;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1905146457:存储容量:6+128GB",
    45. "quantity": 200,
    46. "sku_id": "5142540523709"
    47. },
    48. {
    49. "price": 778,
    50. "total_price": 0,
    51. "orginal_price": 778,
    52. "properties": "1627207:2771458827;5919063:6536025;12304035:1963543205",
    53. "properties_name": "1627207:2771458827:机身颜色:苏音蓝;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1963543205:存储容量:8+128GB",
    54. "quantity": 200,
    55. "sku_id": "5142540523710"
    56. },
    57. {
    58. "price": 868,
    59. "total_price": 0,
    60. "orginal_price": 868,
    61. "properties": "1627207:2771458827;5919063:3266779;12304035:1905146457",
    62. "properties_name": "1627207:2771458827:机身颜色:苏音蓝;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1905146457:存储容量:6+128GB",
    63. "quantity": 0,
    64. "sku_id": "5141622086986"
    65. },
    66. {
    67. "price": 878,
    68. "total_price": 0,
    69. "orginal_price": 878,
    70. "properties": "1627207:2771458827;5919063:3266779;12304035:1963543205",
    71. "properties_name": "1627207:2771458827:机身颜色:苏音蓝;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1963543205:存储容量:8+128GB",
    72. "quantity": 200,
    73. "sku_id": "5141622086987"
    74. },
    75. {
    76. "price": 678,
    77. "total_price": 0,
    78. "orginal_price": 678,
    79. "properties": "1627207:1198972384;5919063:6536025;12304035:1905146457",
    80. "properties_name": "1627207:1198972384:机身颜色:蜜语红;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1905146457:存储容量:6+128GB",
    81. "quantity": 200,
    82. "sku_id": "5142540523705"
    83. },
    84. {
    85. "price": 778,
    86. "total_price": 0,
    87. "orginal_price": 778,
    88. "properties": "1627207:1198972384;5919063:6536025;12304035:1963543205",
    89. "properties_name": "1627207:1198972384:机身颜色:蜜语红;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1963543205:存储容量:8+128GB",
    90. "quantity": 200,
    91. "sku_id": "5142540523706"
    92. },
    93. {
    94. "price": 868,
    95. "total_price": 0,
    96. "orginal_price": 868,
    97. "properties": "1627207:1198972384;5919063:3266779;12304035:1905146457",
    98. "properties_name": "1627207:1198972384:机身颜色:蜜语红;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1905146457:存储容量:6+128GB",
    99. "quantity": 0,
    100. "sku_id": "5141622086984"
    101. },
    102. {
    103. "price": 878,
    104. "total_price": 0,
    105. "orginal_price": 878,
    106. "properties": "1627207:1198972384;5919063:3266779;12304035:1963543205",
    107. "properties_name": "1627207:1198972384:机身颜色:蜜语红;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1963543205:存储容量:8+128GB",
    108. "quantity": 200,
    109. "sku_id": "5141622086985"
    110. },
    111. {
    112. "price": 678,
    113. "total_price": 0,
    114. "orginal_price": 678,
    115. "properties": "1627207:5860482491;5919063:6536025;12304035:1905146457",
    116. "properties_name": "1627207:5860482491:机身颜色:烟雨青蓝;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1905146457:存储容量:6+128GB",
    117. "quantity": 200,
    118. "sku_id": "5142540523711"
    119. },
    120. {
    121. "price": 778,
    122. "total_price": 0,
    123. "orginal_price": 778,
    124. "properties": "1627207:5860482491;5919063:6536025;12304035:1963543205",
    125. "properties_name": "1627207:5860482491:机身颜色:烟雨青蓝;5919063:6536025:套餐类型:官方标配 华为nova5i;12304035:1963543205:存储容量:8+128GB",
    126. "quantity": 200,
    127. "sku_id": "5142540523712"
    128. },
    129. {
    130. "price": 868,
    131. "total_price": 0,
    132. "orginal_price": 868,
    133. "properties": "1627207:5860482491;5919063:3266779;12304035:1905146457",
    134. "properties_name": "1627207:5860482491:机身颜色:烟雨青蓝;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1905146457:存储容量:6+128GB",
    135. "quantity": 0,
    136. "sku_id": "5141622086988"
    137. },
    138. {
    139. "price": 878,
    140. "total_price": 0,
    141. "orginal_price": 878,
    142. "properties": "1627207:5860482491;5919063:3266779;12304035:1963543205",
    143. "properties_name": "1627207:5860482491:机身颜色:烟雨青蓝;5919063:3266779:套餐类型:套餐一 华为nova5por;12304035:1963543205:存储容量:8+128GB",
    144. "quantity": 200,
    145. "sku_id": "5141622086989"
    146. }
    147. ]
    148. },

     

  • 相关阅读:
    shell入门运算符操作、条件判断
    【Android内存溢出分析工具MAT的使用】
    Dubbo链路追踪——生成全局ID(traceId)
    Flowable-流程设计
    wsl2安装rancher并导入和创建k8s集群
    springboot基于JAVA的电影推荐系统的开发与实现毕业设计源码112306
    计算一组Tensor的直方图C算法实现
    介绍ServiceSelf项目
    最新研究综述——探索基础模型中的“幻觉”现象
    Python+selenium自动化环境搭建(安装selenium API库、下载(webdriver)驱动)
  • 原文地址:https://blog.csdn.net/Jernnifer_mao/article/details/134326016