| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | 
							
- const express = require('express')
 
- const app = express()
 
- const port = 3000
 
- app.get('/', (req, res) => {
 
-   res.send('Hello World!欢迎来到协议提取接口服务器')
 
- })
 
- app.get('/scheme', async (req, res) => {
 
-     let copy = req.query.copy
 
-     if(!copy){
 
-         res.json({
 
-             code: 500,
 
-             error:"您缺少copy参数"
 
-         })
 
-         return
 
-     }
 
-     console.log(req.query.copy)
 
-     let schemeURI = await copyToScheme(copy)
 
-     res.json({
 
-         code: 200,
 
-         data:{
 
-             scheme:schemeURI
 
-         }
 
-     })
 
- })
 
- app.listen(port, () => {
 
-   console.log(`Scheme API listening on port http://127.0.0.1:${port}`)
 
- })
 
- async function copyToScheme(copy){
 
-     let shopShareLink = copy
 
-     console.log(shopShareLink)
 
-     let link = extractLinks(shopShareLink)[0]
 
-     console.log(link)
 
-     let response = await fetch(link)
 
-     // let text = await response.text()
 
-     let meituanURL = new URL(response.url)
 
-     console.log(meituanURL)
 
-     let schemeURI = meituanURL.searchParams.get("url")
 
-     console.log(schemeURI)
 
-     return schemeURI
 
- }
 
- function extractLinks(text) {
 
-     // 正则表达式匹配HTTP/HTTPS链接
 
-     // 匹配规则:
 
-     // - 以http://或https://开头
 
-     // - 包含域名(字母、数字、点、下划线、连字符)
 
-     // - 可以包含路径、查询参数和锚点
 
-     const urlRegex = /https?:\/\/[^\s"'<>]+/g;
 
-     
 
-     // 执行匹配并返回结果数组
 
-     // 如果没有找到链接,返回空数组
 
-     return text.match(urlRegex) || [];
 
- }
 
 
  |