【问题标题】:how to open all the links based filename on webpage table in one go and open in new tab如何一次性打开网页表上所有基于链接的文件名并在新选项卡中打开
【发布时间】:2021-05-31 04:21:36
【问题描述】:

必须自动化这项手动工作吗?任何扩展或查询或脚本? 任何想法如何做到这一点

  1. 使用文件名 anyfile.xlsx 打开页面
  2. 右击提交链接和select open in new tab
  3. 将 URL 中的 &ID=9012389 替换为 &thevalue=g 并提交
  4. 重复第 2 步以获取下一个提交链接

【问题讨论】:

    标签: javascript python html anchor browser-automation


    【解决方案1】:

    按 F12 打开 JavaScript 控制台并粘贴

    [...document.querySelectorAll('a')]
        .filter(a => a.href.match(/Submit/))
        .forEach(a => window.open(a.href.replace('&ID=9012389','&thevalue=g'))))
    

    如果控制台要求确认,则允许粘贴。

    【讨论】:

    • 感谢必须在调试器控制台中尝试。更新的网址是 https://api-myurl.com/Lists/checklist?id=312314&runId=113146123&ID=9012389 。我如何根据runid=113146123 过滤所有网址,它是恒定的,然后将&ID=9012389 替换为&thevalue=g
    • .filter(a => a.href.match(/runid=113146123/))
    • urlpath?id=22423&requestId=1614800638070&lD=1​​000018 为什么我们可以替换 &lD=1​​000019, &lD=1​​000023, &lD=1​​000045, &lD=1​​000215....等等最多 50 个 id?与 &thevalue=g ?或&ID 中的任何值都可以使用ID=@"^\d{10}$"
    • 打印在哪里?安慰? [...document.querySelectorAll('a')].filter(a => a.href.match(/requestId=*?/)).forEach(a => console.log(a.outerHTML))
    • [...document.querySelectorAll('a')].filter(a => a.href.match(/requestId=*?/)).forEach(a => console.log(a.outerHTML.replace(/&ID=[0-9]+/,'&thevalue=g')))
    猜你喜欢
    • 2017-01-05
    • 2012-04-25
    • 1970-01-01
    • 2020-12-11
    • 2020-12-07
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    相关资源
    最近更新 更多