如何在移动应用程序中从维基百科 api 重新设置 Json 样式?

发布于 2025-01-07 09:57:32 字数 382 浏览 3 评论 0原文

我想重新设计维基百科文章的部分并将这些部分嵌入到移动应用程序中。

我尝试使用 http://en.wikipedia.org/w/api.php?action=parse&format=json&page=New_York 但 json 文件中的文本包含 mediawiki 的格式。

如何在没有 mediawiki 平台的情况下维护其他页面的链接,以便它们显示在移动(或网络)应用程序中? 例如

例如

<a href="/wiki/Wikipedia:IPA_for _English # Key" title="Wikipedia:IPA \
for English">

I'd like to restyle part of wikipedia articles and embed these parts into mobile app.

I tried to use
http://en.wikipedia.org/w/api.php?action=parse&format=json&page=New_York
but text in json files contains formatting for mediawiki.

How to maintain links to other pages without a mediawiki platform, so that they are displayed within the mobile (or web) app?
e.g.

e.g.

<a href="/wiki/Wikipedia:IPA_for _English # Key" title="Wikipedia:IPA \
for English">

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

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

发布评论

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

评论(1

甜警司 2025-01-14 09:57:32

呵呵,是的,当我不知道如何使用 javascript 编程时,这是我的第一个问题。
初学者提出问题的方式很有趣:)
如果有什么有用的东西可以分享,我会时不时地回到我的旧问题并回答它们。

回答我自己的问题:
有可能劫持链接

为了简单起见,这里使用 jquery,可以选择具有模式的 标签,然后将函数绑定到它们。

例子:

$("a[href*='/wiki/']").click(function(e){
  // capture the link 
var link  = this.href;
// do something else..
}

hehe, yes, this was one of my first questions when I did not know about programming with javascript.
It is funny how questions are posed when beginner :)
Here and then I will go back to old questions of mine and answer them if something useful to share.

To answer my own question:
it is possible to hijack a link.

using jquery here for simplicity, it is possible to select <a> tags that have a pattern and then bind a function to them.

Example:

$("a[href*='/wiki/']").click(function(e){
  // capture the link 
var link  = this.href;
// do something else..
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文