如何从公共JS脚本中检索价值?
我正在对加密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?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.