更新
This commit is contained in:
19
public/rules_2.json
Normal file
19
public/rules_2.json
Normal file
@@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"id": 12,
|
||||
"priority": 1,
|
||||
"action": {
|
||||
"type": "modifyHeaders",
|
||||
"requestHeaders": [
|
||||
{
|
||||
"header": "Origin",
|
||||
"operation": "set",
|
||||
"value": "https://www.temu.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"urlFilter": "||www.temu.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -35,6 +35,10 @@
|
||||
"id": "1",
|
||||
"enabled": true,
|
||||
"path": "rules_1.json"
|
||||
},{
|
||||
"id": "2",
|
||||
"enabled": true,
|
||||
"path": "rules_2.json"
|
||||
}]
|
||||
},
|
||||
"content_scripts": [
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
"id": "1",
|
||||
"enabled": true,
|
||||
"path": "rules_1.json"
|
||||
},{
|
||||
"id": "2",
|
||||
"enabled": true,
|
||||
"path": "rules_2.json"
|
||||
}]
|
||||
},
|
||||
"content_scripts": [
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sendTemuAPIMessage} from '@/api/chromeApi'
|
||||
import {sendChromeWebReqMessage} from '@/api/chromeApi'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: 'List',
|
||||
@@ -201,55 +202,53 @@ import {sendTemuAPIMessage} from '@/api/chromeApi'
|
||||
this.beginCollect(row)
|
||||
},
|
||||
beginCollect(row) {
|
||||
sendTemuAPIMessage({
|
||||
url: 'api/poppy/v1/search?scene=search',
|
||||
anti: true,
|
||||
data:
|
||||
{
|
||||
"scene": "search",
|
||||
"offset": (this.pageNo-1) * this.pageSize,
|
||||
"pageSize": 120,
|
||||
"query": row.content,
|
||||
"filterItems": row.orderType,
|
||||
"searchMethod": "suggest"
|
||||
}}).then((res) => {
|
||||
this.isLoading = false
|
||||
if (res.success) {
|
||||
res.result.data.goods_list.map(item => {
|
||||
let total = 0
|
||||
if (item.sales_tip_text[0]) {
|
||||
total = item.sales_tip_text[0]
|
||||
total = total.replace('+', '')
|
||||
if (total.indexOf('K') != -1) {
|
||||
total = total.replace('K', '')
|
||||
total = total * 1000
|
||||
} else if (total.indexOf('M') != -1) {
|
||||
total = total.replace('M', '')
|
||||
total = total * 1000000
|
||||
}
|
||||
}
|
||||
this.detailsVo.details.push({
|
||||
url: item.link_url,
|
||||
price: item.price_info.price_schema,
|
||||
saleTotal: total,
|
||||
goodsId: item.goods_id,
|
||||
imgUrl: item.thumb_url,
|
||||
mallId: item.mall_id
|
||||
})
|
||||
})
|
||||
console.log(this.detailsVo)
|
||||
sendChromeWebReqMessage({
|
||||
type: 'temu',
|
||||
url: 'https://www.temu.com/search_result.html?search_key='+row.content+'&search_method=user&filter_items='+row.orderType
|
||||
}).then((res) => {
|
||||
this.isLoading = false
|
||||
if (res.indexOf("rawData") == -1) {
|
||||
Message.error("请检查地址是否正确,或者“TEMU”网站是否出现图形验证码")
|
||||
return
|
||||
}
|
||||
let str = res.substring(res.indexOf("rawData"))
|
||||
str = str.substring(0, str.indexOf("<\/script>"))
|
||||
str = str.substring(str.indexOf("{"))
|
||||
str = str.substring(0, str.lastIndexOf("}"))
|
||||
str = str + "}"
|
||||
let obj = JSON.parse(str)
|
||||
let goodsList = obj.store.goodsList
|
||||
goodsList.map(t => {
|
||||
let item = t.data
|
||||
let total = 0
|
||||
if (item.salesNum) {
|
||||
total = item.salesNum
|
||||
total = total.replace('+', '')
|
||||
if (total.indexOf('K') != -1) {
|
||||
total = total.replace('K', '')
|
||||
total = total * 1000
|
||||
} else if (total.indexOf('M') != -1) {
|
||||
total = total.replace('M', '')
|
||||
total = total * 1000000
|
||||
}
|
||||
}
|
||||
this.detailsVo.details.push({
|
||||
url: item.linkUrl,
|
||||
price: item.priceInfo.priceSchema,
|
||||
saleTotal: total,
|
||||
goodsId: item.goodsId,
|
||||
imgUrl: item.thumbUrl,
|
||||
mallId: item.mallId
|
||||
})
|
||||
})
|
||||
|
||||
this.$http.post('/api/monitorDetail/addDetails',this.detailsVo
|
||||
).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('关键字【' + row.content + '】数据采集成功!')
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error("采集失败,请检查网络情况")
|
||||
this.$http.post('/api/monitorDetail/addDetails',this.detailsVo).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('关键字【' + row.content + '】数据采集成功!')
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user