得物API,按得物spu_id采集得物商品详细、商品价格等数据

😁如有侵权,请联系删除。


1、得物商品详情

/server/api/dewu/goodsPrice
import http.client
conn = http.cimport http.client

conn = http.client.HTTPSConnection("prod-cn.your-api-server.com")
payload = ''
headers = {
   'User-Agent': 'Apifox/1.0.0 (https://www.apifox.cn)'
}
conn.request("GET", "/server/api/dewu/goodsDetail?appkey=&spu_id=", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))lient.HTTPSConnection("prod-cn.your-api-server.com")payload = ''headers = {   'User-Agent': 'Apifox/
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是基于Scala语言的代码: ```scala import org.apache.spark.sql.functions._ import org.apache.spark.ml.feature.{StandardScaler, OneHotEncoder, StringIndexer} // 读取Hive中的dwd库中相关表 val df = spark.sql("select id, spu_id, price, weight, tm_id, category3_id from dwd_table") // 读取MySQL中shtd_store中相关商品表 // val df = spark.read.jdbc(url, table, properties) // 规范化price和weight字段 val scaler = new StandardScaler() .setInputCol("features") .setOutputCol("scaled_features") .setWithStd(true) .setWithMean(true) val assembler = VectorAssembler() .setInputCols(Array("price", "weight")) .setOutputCol("features") val scaledDF = scaler.fit(assembler.transform(df)).transform(assembler.transform(df)) // 对spu_id、tm_id、category3_id进行one-hot编码 val spuIndexer = new StringIndexer() .setInputCol("spu_id") .setOutputCol("spu_index") .setHandleInvalid("skip") val tmIndexer = new StringIndexer() .setInputCol("tm_id") .setOutputCol("tm_index") .setHandleInvalid("skip") val categoryIndexer = new StringIndexer() .setInputCol("category3_id") .setOutputCol("category_index") .setHandleInvalid("skip") val encoder = new OneHotEncoder() .setInputCols(Array("spu_index", "tm_index", "category_index")) .setOutputCols(Array("spu_encoded", "tm_encoded", "category_encoded")) val oneHotDF = encoder.fit(categoryIndexer.fit(tmIndexer.fit(spuIndexer.fit(scaledDF).transform(scaledDF)).transform(scaledDF)).transform(scaledDF) // 按照id进行升序排序,并输出前10行 val resultDF = oneHotDF.sort("id").limit(10).select("id", "spu_encoded", "tm_encoded", "category_encoded", "scaled_features") resultDF.show(false) ``` 其中,需要替换以下内容: 1. `dwd_table`:Hive中的相关表名; 2. `url`、`table`、`properties`:MySQL中相关表的连接信息; 3. `Array("price", "weight")`:需要规范化的字段名; 4. `Array("spu_index", "tm_index", "category_index")`:需要进行one-hot编码的字段名; 5. `"skip"`:空值处理策略,可选值为`"skip"`、`"error"`和`"keep"`,表示跳过、报错或保留空值。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值