javascript - 抓取: Get Link that is only visible on the website not in the html

标签 javascript node.js web-scraping nightmare

所以我在一个网站上,我想获得一个链接。我要获取的链接显示在网站上,但在html文件中不可见。有一个复制按钮,可将链接复制到剪贴板。我想获得链接,有人知道我如何获得它吗?
html看起来像这样:

<div class="containerInvite">
      <div class="title">Invite your friends!</div>
      <div class="inviteBar">
        <input type="text" readonly id="invite">  --Here should be the link
        <button class="button btn btn-primary" 
         id="inviteCopyButton">Copy</button> --The Button that copies the link
      </div>
    </div>

最佳答案

要仅从javascript中读取id="invite"输入的值,请使用:

document.getElementById("invite").value;

如果您希望按钮将值复制到剪贴板中,请创建一个函数
function copyLink() {
  //Get the text field
  var copyText = document.getElementById("invite");
  //Select the text field
  copyText.select();
  //Copy the text inside the text field
  document.execCommand("copy");
}

然后加
onclick="copyLink()"

在您的按钮中。或附加“点击”事件

关于javascript - 抓取: Get Link that is only visible on the website not in the html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52513120/

相关文章:

javascript - 将元素内的所有子元素减少一定百分比?

javascript - 链接 parentNode 调用

node.js - NodeJs 类型错误 : Cannot read property 'key' of undefined

python - 如何删除字符串右侧的多余文本?

javascript - 我的 javascript 代码中的 Python getattr 等效项?

javascript - 在 NodeList 对象的 Object.prototype 上实现 Array 方法是一个好习惯吗?

node.js - 错误: getaddrinfo ENOTFOUND while making get request to localhost, Nodejs

javascript - 用axios发送Blob到服务器,接收到一个空对象

python - Newspaper3k : How to Scrape ONLY Article HTML? Python 的缺点

python - 从 BeautifulSoup 结果集中分离元素