javascript - Webscraping:获取仅在网站上可见而不在 html 中可见的链接
问题描述
所以我在一个网站上,我想获得一个链接。我想获取的链接显示在网站上,但在 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>
解决方案
id="invite"
要从 javascript中读取输入值,请使用:
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()"
在您的按钮中。或附加一个“点击”事件
推荐阅读
- jquery - 截屏并显示在 Angular 1.6 的新弹出窗口/选项卡中
- azure-virtual-machine - 我的 Azure 门户中突然停止了 100 个 Vm
- elf - ELF - sh_offset 字段的目的是什么?
- ios - 从 xmpp 服务器获取归档消息 - Swift
- yaml - Ansible/yaml:for 语法中的 if 语法
- spring-boot - 在 Spring Boot 中的 @Transactional 方法之后,实体未在 Exposed 中持久化
- javascript - 在 React Js 中禁用元素
- jquery - 将内联样式添加到可见的最后一个孩子
- sql-server - SQL Server 查询 if then 逻辑
- mathjax - 在 MathJax 等浏览器中使用 TikZ