Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
b66952ad
authored
May 20, 2023
by
stakeswky
Committed by
GitHub
May 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create useSearch.ts (#35)
联网功能
parent
242b2126
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
src/service/plugins/useSearch.ts
+35
-0
No files found.
src/service/plugins/useSearch.ts
0 → 100644
View file @
b66952ad
import
axios
from
'axios'
;
{
/*Bing 搜索*/
}
const
BingSearch
=
async
(
wait_val
:
string
)
=>
{
const
response
=
await
axios
.
post
(
"newbing中转服务器"
,
{
prompt
:
wait_val
,
});
const
result
=
response
.
data
.
result
;
return
result
;
};
{
/*google 搜索*/
}
const
GoogleSearch
=
async
(
wait_val
:
string
)
=>
{
const
response
=
await
axios
.
get
(
'https://www.googleapis.com/customsearch/v1'
,
{
params
:
{
key
:
google_api
,
q
:
wait_val
,
cx
:
searchEngineId
,
start
:
1
,
num
:
3
,
dateRestrict
:
'm[1]'
,
//搜索结果限定为一个月内
},
});
const
results
=
response
.
data
.
items
;
if
(
results
!==
null
)
{
const
result
=
results
.
map
((
item
:
{
snippet
:
string
})
=>
item
.
snippet
).
join
(
'\n'
);
return
result
;
}
}
export
{
BingSearch
,
GoogleSearch
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment