index.html 1.4 KB

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