1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
-
- <script>
- function extractLinks(text) {
- // 正则表达式匹配HTTP/HTTPS链接
- // 匹配规则:
- // - 以http://或https://开头
- // - 包含域名(字母、数字、点、下划线、连字符)
- // - 可以包含路径、查询参数和锚点
- const urlRegex = /https?:\/\/[^\s"'<>]+/g;
-
- // 执行匹配并返回结果数组
- // 如果没有找到链接,返回空数组
- return text.match(urlRegex) || [];
- }
- async function goShop(){
- let shopShareLink = `【瑞幸咖啡(南昌紫荆夜市步行街店)】快来试试这家餐厅吧! 【地址:新建区经济开发区紫荆路商业步行街西1栋粤客隆商场底商】【电话:4000100100】@美团 http://dpurl.cn/tcpS5omz`
- let links = extractLinks(shopShareLink)
- console.log(links)
- return
- // window.open("http://dpurl.cn/tcpS5omz")
- let response = await fetch("http://dpurl.cn/tcpS5omz")
- let text = await response.text()
- console.log(text)
- }
- </script>
- <button onclick="goShop()">进入美团门店</button>
- </body>
- </html>
|