在Plotly仪表板中显示文本/链接

发布于 2025-02-13 21:38:43 字数 1396 浏览 1 评论 0原文

我一直在尝试最长的时间来解决这个问题。我只想从此功能中获取输出,然后将其放入DASH应用程序页面。 我已经尝试了DCC.markDown,但它完全按照书面形式显示文本。 我没有输入,所以我不确定如何没有一个输入。

将是最简单的方法吗?

url1 = "https://google-news1.p.rapidapi.com/search"
querystring1 = {"q":"bitcoin","lang":"en","limit":"10","when":"1h","exact_phrase":"bitcoin"}
headers1 = {
    "X-RapidAPI-Key": "XXXXXXXXX",
    "X-RapidAPI-Host": "google-news1.p.rapidapi.com"
}
response1 = requests.request("GET", url1, headers=headers1, params=querystring1).json()

def get_news():
    for x in response1['articles']:
        title = (x['title'])
        link = (x['link'])
        print(f"{title}\n{link}")
        
get_news()

代码将返回这样的东西:

迈克尔·赛勒(Michael Saylor)现在对比特币有什么看法? -Motley傻瓜 https://www.fool.com/investing/2022/07/06/what what what-michael-saylor-thinks-bitcoin-bitcoin-right-now/

binance删除了第五届周年纪念日的比特币交易费用比特币杂志 https://bitcoinmagazine.com/business/binance-removes-bitcoin-trading-费用

等...

我只想要这个,但是在dash应用程序上通过plotly。无需搜索或任何内容,只要页面加载即可刷新。

提前致谢!

I've been trying for the longest to figure this out. I would just like to take the output from this function and make it into a dash app page.
I've tried dcc.Markdown but it displays the text exactly as written.
I don't have an input so I'm not sure how to callback what I want without one.

Would would be the easiest way to go about it?

url1 = "https://google-news1.p.rapidapi.com/search"
querystring1 = {"q":"bitcoin","lang":"en","limit":"10","when":"1h","exact_phrase":"bitcoin"}
headers1 = {
    "X-RapidAPI-Key": "XXXXXXXXX",
    "X-RapidAPI-Host": "google-news1.p.rapidapi.com"
}
response1 = requests.request("GET", url1, headers=headers1, params=querystring1).json()

def get_news():
    for x in response1['articles']:
        title = (x['title'])
        link = (x['link'])
        print(f"{title}\n{link}")
        
get_news()

the code will return something like this:

What Does Michael Saylor Think of Bitcoin Right Now? - The Motley Fool
https://www.fool.com/investing/2022/07/06/what-michael-saylor-thinks-of-bitcoin-right-now/

Binance Removes Bitcoin Trading Fees In Fifth Anniversary - Bitcoin Magazine
https://bitcoinmagazine.com/business/binance-removes-bitcoin-trading-fees

etc...

I just want this, but on a dash app via Plotly. No search or anything needed, it would just refresh whenever the page loads.

Thanks in advance!

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

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

发布评论

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

评论(1

如梦亦如幻 2025-02-20 21:38:44

设置您的初始布局,然后使用回调来填充文本和链接,通过收听dcc.location组件并输出到布局中的某些容器。这将使页面加载时运行。只需将每个项目放入dcc.link中。

Set up your initial layout, and then use a callback to populate the text and links by listening to a dcc.Location component and outputting to some container in the layout. That will make it run when the page loads. Just put each item into a dcc.Link.

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