如何从公共JS脚本中检索价值?

发布于 2025-02-12 22:59:41 字数 799 浏览 0 评论 0原文

我正在对加密API进行研究,并希望获得硬币的当前价格。我使用 tradingview widget widget在我的网页上显示所有图表和数据。因此,现在我只想从小部件中检索当前的价格,是否有可能?

尝试了什么:

此小部件在iframe中,所以我尝试调用docuct.getElementsbytagname('iframe')[0] .contentwindow.document.document.body.innertext;,但不幸的是,它显示出block block oin访问交叉原始框架。有人知道从JS脚本中检索这些价值的方法吗?

对于完整的代码,我不能在这里粘贴它,因为Stackoverflow已阻止了它,可以转到此 page 生成小部件

Im doing a research on Crypto API and want to get the current price of a coin. I used TradingView widget to display all the chart and data on my webpage. So now I only want to retrieve the current price from the widget, is it possible? enter image description here

What've tried:

This widget is in iframe, so i tried to called document.getElementsByTagName('iframe')[0].contentWindow.document.body.innerText; But unfortunately, it showed Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame. Does anyone know ways to retrieve these value from the JS script?

For the full code I cant paste it here because stackoverflow blocked it, can go to this page to generate widget

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

信仰 2025-02-19 22:59:41

This is the tradingview api https://www.tradingview.com/rest- API-SPEC/#操作/GetQuotes
您可以使用用户名和密码进行身份验证。如果您想访问数据,则需要使用API​​或采用某种网络爬行方法。出于安全原因,iframe和该页面上的cookie中的数据受到保护,因此您将无法以这种方式掌握它们。

This is the tradingview api https://www.tradingview.com/rest-api-spec/#operation/getQuotes.
You can authenticate using username and password. If you want access to the data you will need to use the api or go with some kind of web crawling approach. The data in iframes as well as the cookies on that page are protected from you for security reasons so you wont be able to get a hold of them in that way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文