-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(route): 新增 bing 搜索; 迁移 bing 每日图片到 v2; 新增 百度搜索; 迁移 搜狗特色LOGO 到 v2 规范;添加 搜狗搜索;添加 Google Search #13936
Merged
Merged
feat(route): 新增 bing 搜索; 迁移 bing 每日图片到 v2; 新增 百度搜索; 迁移 搜狗特色LOGO 到 v2 规范;添加 搜狗搜索;添加 Google Search #13936
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
83a7846
fix(route): 修复 米游社 公告栏 template 错误
CaoMeiYouRen 7b65948
Merge branch 'DIYgod:master' into master
CaoMeiYouRen 2ea08ff
feat(route): 新增 bing 搜索
CaoMeiYouRen de072b3
docs: Update other.mdx
CaoMeiYouRen 98aee17
docs: fix docs
TonyRL 13b91e1
feat(route): 新增 百度搜索
CaoMeiYouRen 32d028a
Merge branch 'master' of github.com:CaoMeiYouRen/RSSHub
CaoMeiYouRen dd283a2
fix(route): 修复 pubDate 解析错误
CaoMeiYouRen 288b606
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen b0b6b4d
fix(route): 优化 百度搜索的缓存,减轻反爬问题
CaoMeiYouRen e9afda3
feat(route): 新增 360 搜索
CaoMeiYouRen 3171faa
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 7abe59c
feat(route): 迁移 搜狗特色LOGO 到 v2 规范;添加 搜狗搜索
CaoMeiYouRen 4751557
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 7f68ac2
fix(route): 百度搜索增加图片
CaoMeiYouRen 12d0477
feat(route): 新增 Google Search
CaoMeiYouRen f81821d
chore: merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 05ce45c
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 1185a64
fix(route): 修复 百度搜索相关问题
CaoMeiYouRen 58c722d
fix(route): 修复 Google 相关问题
CaoMeiYouRen 1b00eb6
fix(route): 修复 360 搜索
CaoMeiYouRen 08dca4d
fix(route): 修复 搜狗搜索
CaoMeiYouRen 90b1aa7
fix(route): 修复 await 问题
CaoMeiYouRen da49d03
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 931b769
fix: 移除 google sites
CaoMeiYouRen a997c01
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 22923a5
fix(route): 修复 缓存和过滤逻辑问题
CaoMeiYouRen 90ebcd6
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen cd5d832
fix(route): 修复 360 搜索缺少 cookie 的问题
CaoMeiYouRen 31118c2
fix(route): 修复 360 搜索 cookie 的问题
CaoMeiYouRen 219f9d8
feat(route): 移除 so.com 路由
CaoMeiYouRen c548af5
fix: merge conflict
TonyRL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); | ||
const config = require('@/config').value; | ||
|
||
module.exports = async (ctx) => { | ||
const { keyword } = ctx.params; | ||
const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`; | ||
const key = `baidu-search:${url}`; | ||
|
||
const items = await ctx.cache.tryGet( | ||
key, | ||
async () => { | ||
const response = (await got(url)).data; | ||
const visitedLinks = new Set(); | ||
const $ = cheerio.load(response); | ||
const contentLeft = $('#content_left'); | ||
const containers = contentLeft.find('.c-container'); | ||
return containers | ||
.map((i, el) => { | ||
const element = $(el); | ||
const link = element.find('h3 a').first().attr('href'); | ||
if (link && !visitedLinks.has(link)) { | ||
visitedLinks.add(link); | ||
const imgs = element | ||
.find('img') | ||
.map((_j, _el) => $(_el).attr('src')) | ||
.toArray(); | ||
const description = element.find('.c-gap-top-small [class^="content-right_"]').first().text() || element.find('.c-row').first().text() || element.find('.cos-row').first().text(); | ||
return { | ||
title: element.find('h3').first().text(), | ||
description: renderDescription(description, imgs), | ||
link: element.find('h3 a').first().attr('href'), | ||
author: element.find('.c-row .c-color-gray').first().text() || '', | ||
}; | ||
} | ||
return null; | ||
}) | ||
.toArray() | ||
.filter((e) => e?.link); | ||
}, | ||
config.cache.routeExpire, | ||
false | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${keyword} - 百度搜索`, | ||
description: `${keyword} - 百度搜索`, | ||
link: url, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{@ description }} | ||
{{if images}} | ||
{{each images}} | ||
<img src="{{ $value }}"> | ||
{{/each}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
'/': ['FHYunCai'], | ||
'/search/:keyword': ['CaoMeiYouRen'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
'bing.com': { | ||
_name: 'Bing', | ||
cn: [ | ||
{ | ||
title: '每日壁纸', | ||
docs: 'https://docs.rsshub.app/routes/picture#bing', | ||
source: '/', | ||
target: '/bing', | ||
}, | ||
{ | ||
title: '搜索', | ||
docs: 'https://docs.rsshub.app/routes/other#bing', | ||
source: '/', | ||
target: (params, url) => { | ||
const q = new URL(url).searchParams.get('q'); | ||
return `/bing/search/${q}`; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function (router) { | ||
router.get('/', require('./daily-wallpaper')); | ||
router.get('/search/:keyword', require('./search')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const parser = require('@/utils/rss-parser'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const dayjs = require('dayjs'); | ||
const localizedFormat = require('dayjs/plugin/localizedFormat'); | ||
require('dayjs/locale/zh-cn'); | ||
dayjs.extend(localizedFormat); | ||
|
||
module.exports = async (ctx) => { | ||
const q = ctx.params.keyword; | ||
const searchParams = new URLSearchParams({ | ||
format: 'rss', | ||
q, | ||
}); | ||
const url = new URL('https://cn.bing.com/search'); | ||
url.search = searchParams.toString(); | ||
const data = await parser.parseURL(url.toString()); | ||
ctx.state.data = { | ||
title: data.title, | ||
link: data.link, | ||
description: data.description + ' - ' + data.copyright, | ||
image: data.image.url, | ||
item: data.items.map((e) => ({ | ||
...e, | ||
description: e.content, | ||
pubDate: parseDate(e.pubDate, 'dddd, DD MMM YYYY HH:mm:ss [GMT]', 'zh-cn'), | ||
})), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const config = require('@/config').value; | ||
|
||
const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); | ||
|
||
module.exports = async (ctx) => { | ||
const { keyword, language } = ctx.params; | ||
const searchParams = new URLSearchParams({ | ||
q: keyword, | ||
}); | ||
const tempUrl = new URL('https://www.google.com/search'); | ||
tempUrl.search = searchParams.toString(); | ||
const url = tempUrl.toString(); | ||
const key = `google-search:${language}:${url}`; | ||
const items = await ctx.cache.tryGet( | ||
key, | ||
async () => { | ||
const response = ( | ||
await got(url, { | ||
headers: { | ||
'Accept-Language': language, | ||
}, | ||
}) | ||
).data; | ||
const $ = cheerio.load(response); | ||
const content = $('#rso'); | ||
return content | ||
.find('> div') | ||
.map((i, el) => { | ||
const element = $(el); | ||
const link = element.find('div > div > div > div > div > span > a').first().attr('href'); | ||
const title = element.find('div > div > div> div > div > span > a > h3').first().text(); | ||
const imgs = element | ||
.find('img') | ||
.map((_j, _el) => $(_el).attr('src')) | ||
.toArray(); | ||
const description = element.find('div[style="-webkit-line-clamp:2"]').first().text() || element.find('div[role="heading"]').first().text(); | ||
const author = element.find('div > div > div > div > div > span > a > div > div > span').first().text() || ''; | ||
return { | ||
link, | ||
title, | ||
description: renderDescription(description, imgs), | ||
author, | ||
}; | ||
}) | ||
.toArray() | ||
.filter((e) => e?.link); | ||
}, | ||
config.cache.routeExpire, | ||
false | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${keyword} - Google Search`, | ||
description: `${keyword} - Google Search`, | ||
link: url, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{@ description }} | ||
{{if images}} | ||
{{each images}} | ||
<img src="{{ $value }}"> | ||
{{/each}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/search/:keyword': ['CaoMeiYouRen'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
'so.com': { | ||
_name: '360 公司', | ||
www: [ | ||
{ | ||
title: '搜索', | ||
docs: 'https://docs.rsshub.app/routes/other#360-sou-suo-sou-suo', | ||
source: '/', | ||
target: (params, url) => { | ||
const q = new URL(url).searchParams.get('q'); | ||
return `/so/search/${q}`; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/search/:keyword', require('./search')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const config = require('@/config').value; | ||
|
||
const renderDescription = (description, images) => art(path.join(__dirname, './templates/description.art'), { description, images }); | ||
|
||
module.exports = async (ctx) => { | ||
const { keyword } = ctx.params; | ||
const url = `https://www.so.com/s?q=${encodeURIComponent(keyword)}`; | ||
const key = `360-so-search:${url}`; | ||
const items = await ctx.cache.tryGet( | ||
key, | ||
async () => { | ||
const response = (await got(url)).data; | ||
const $ = cheerio.load(response); | ||
const result = $('#container .result'); | ||
const resList = result.find('.res-list'); | ||
return resList | ||
.map((i, el) => { | ||
const element = $(el); | ||
const imgs = element | ||
.find('img') | ||
.map((j, el2) => $(el2).attr('src')) | ||
.toArray(); | ||
const description = element.find('.res-desc').first().text() || element.find('.mh-content-desc-info').first().text() || element.find('.res-comm-con').first().text(); | ||
return { | ||
link: element.find('h3 a').first().attr('href'), | ||
title: element.find('h3').first().text(), | ||
description: renderDescription(description, imgs), | ||
author: element.find('.g-linkinfo cite').first().text() || '', | ||
}; | ||
}) | ||
.toArray() | ||
.filter((e) => e?.link); | ||
}, | ||
config.cache.routeExpire, | ||
false | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${keyword} - 360 搜索`, | ||
description: `${keyword} - 360 搜索`, | ||
link: url, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{@ description }} | ||
{{if images}} | ||
{{each images}} | ||
<img src="{{ $value }}"> | ||
{{/each}} | ||
{{/if}} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
'/doodles': ['xyqfer'], | ||
'/search/:keyword': ['CaoMeiYouRen'], | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This request requires cookie.
https://github.com/DIYgod/RSSHub/actions/runs/7309647602/job/19917459502#step:12:35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I will fix this issue as soon as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I have tried several ways to solve the issue, but I still cannot pass the GitHub Action request.
I tested it locally and did not encounter the MaxRedirectsError or cookie problem. Even when accessing it through a proxy, I did not encounter this issue.
Therefore, I suspect it is an IP issue with GitHub Action, and there may be some restrictions on so.com.
If it doesn't work, I will temporarily remove the route to so.com to ensure that other changes can be merged in.