This commit is contained in:
liushiwei
2023-10-17 14:03:25 +08:00
parent de0229419b
commit 17986a574b
4 changed files with 73 additions and 47 deletions

19
public/rules_2.json Normal file
View 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"
}
}
]

View File

@@ -35,6 +35,10 @@
"id": "1",
"enabled": true,
"path": "rules_1.json"
},{
"id": "2",
"enabled": true,
"path": "rules_2.json"
}]
},
"content_scripts": [

View File

@@ -35,6 +35,10 @@
"id": "1",
"enabled": true,
"path": "rules_1.json"
},{
"id": "2",
"enabled": true,
"path": "rules_2.json"
}]
},
"content_scripts": [

View File

@@ -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()
}
})
})
}
}
}