如何获取堆栈交换 API 使用的所有标签的 JSON 响应

how to get json responses for all the tags used by stackexchange API

本文关键字:标签 响应 JSON API 何获取 获取 交换 堆栈      更新时间:2023-09-26

https://stackoverflow.com/tags/synonyms?page=1&tab=newest&filter=allgetbootstrap.com

这让我返回了 html 页面,那么如何将标签转换为可以填充到我的自动完成搜索框中的 json 数组

https://i.stack.imgur.com/j9Wvy.jpg "tags_image_return_html"

您是否尝试过查看堆栈溢出API。有一个终结点提供 JSON 格式的响应,请在此处查看标记 API:https://api.stackexchange.com/docs/tags#order=desc&sort=popular&filter=default&site=stackoverflow&run=true

不鼓励从页面中抓取 HTML,因为您无法保证页面的格式保持不变,这也意味着您需要做更多的处理才能获得所需的数据。

此外,通过使用 JSON 资源,您可以使用 Select2 等库来使您的生活更加轻松。