From 138b70263a0ae6f0afb8bc384f816d8b7a707229 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sun, 30 Aug 2020 11:18:42 +0200 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B1=86=E7=93=A3=E8=AF=84?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Detail.vue | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/components/Detail.vue b/src/components/Detail.vue index b6e7577..084549b 100644 --- a/src/components/Detail.vue +++ b/src/components/Detail.vue @@ -25,6 +25,7 @@
上映: {{info.year}}
更新: {{info.last}}
备注: {{info.note}}
+
豆瓣评分: {{info.rate}}
@@ -210,12 +211,41 @@ export default { } }) }, + getDoubanRate () { + const axios = require('axios') + const cheerio = require('cheerio') + const name = this.detail.info.name.trim() + // 豆瓣搜索链接 + var doubanSearchLink = 'https://www.douban.com/search?q=' + name + axios.get(doubanSearchLink).then(res => { + const $ = cheerio.load(res.data) + // 得到豆瓣搜索的第一条结果 + var nameInDouban = $('div.result').first().find('div>div>h3>a').first() + // 如果第一条结果就是该影片,打开该链接获取评分 + if (name === nameInDouban.text().trim()) { + var link = nameInDouban.attr('href') + axios.get(link).then(response => { + const parsedHtml = cheerio.load(response.data) + var rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first() + if (rating.text()) { + this.info.rate = rating.text() + } else { + this.info.rate = '暂无评分' + } + }) + } else { + this.info.rate = '暂无评分' + } + }) + }, getDetailInfo () { const id = this.detail.info.ids || this.detail.info.id zy.detail(this.detail.key, id).then(res => { if (res) { this.info = res + this.$set(this.info, 'rate', '') this.m3u8Parse(res) + this.getDoubanRate() this.loading = false } }) @@ -286,6 +316,11 @@ export default { font-size: 14px; line-height: 26px; } + .rate{ + font-size: 16px; + line-height: 26px; + font-weight: bolder; + } } } .operate{