正在寻找一个 wikipedia api 可以为我提供 XML 格式的文章

发布于 2024-12-27 09:52:10 字数 174 浏览 1 评论 0 原文

我正在寻找一个维基百科 api,它可以为我提供相应查询的文章(无图像)。 我已经看到 wikipedia api 与 actions=opensearchquery=search 一起使用。 请告诉我哪一个是正确的,或者是否还有我应该使用的其他操作

I am looking for a wikipedia api that can give me an article (no image) to a respective query.
I have seen the wikipedia api used with actions=opensearch and query=search.
Please tell me which one is correct or if there is any other action I should use.

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

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

发布评论

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

评论(1

逆夏时光 2025-01-03 09:52:11

请参阅 WikiMedia API 帮助完整文档

目前尚不清楚您希望返回什么内容,是文章还是搜索结果。无论哪种方式,要获取 xml 格式的结果,请使用 format=xml

要获取与特定查询匹配的文章列表,请使用 opensearch 操作。例如:
http://en.wikipedia.org/w/api.php?action=opensearch&search=MediaWiki&format=xml - 查看结果

action=opensearch 部分href="http://en.wikipedia.org/w/api.php" rel="nofollow">API 帮助

* action=opensearch *
  Searches the wiki using the OpenSearch protocol

This module requires read rights
Parameters:
  search     - Search string
  limit      - Maximum amount of results to return
               No more than 100 (100 for bots) allowed
               Default: 10
  namespace  - Namespaces to search
               Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
                   13, 14, 15
               Maximum number of values 50 (500 for bots)
               Default: 0
  suggest    - Do nothing if $wgEnableOpenSearchSuggest is false
  format     - Output format defaults to JSON, with expanded XML optional.
               One value: json, jsonfm, xml, xmlfm
               Default: json
Example:
  api.php?action=opensearch&search=Te

要获取特定文章的内容,请使用 解析操作。例如:
http://en.wikipedia.org/w/api.php?action=parse&page=MediaWiki&format=xml - 查看结果

action=parse 部分href="http://en.wikipedia.org/w/api.php" rel="nofollow">API 帮助

* action=parse *
  Parses wikitext and returns parser output

This module requires read rights
Parameters:
  title       - Title of page the text belongs to
                Default: API
  text        - Wikitext to parse
  summary     - Summary to parse
  page        - Parse the content of this page. Cannot be used together with
                    text and title
  pageid      - Parse the content of this page. Overrides page
  redirects   - If the page or the pageid parameter is set to a redirect, resolve it
  oldid       - Parse the content of this revision. Overrides page and pageid
  prop        - Which pieces of information to get
                 text           - Gives the parsed text of the wikitext
                 langlinks      - Gives the language links in the parsed wikitext
                 categories     - Gives the categories in the parsed wikitext
                 categorieshtml - Gives the HTML version of the categories
                 languageshtml  - Gives the HTML version of the language links
                 links          - Gives the internal links in the parsed wikitext
                 templates      - Gives the templates in the parsed wikitext
                 images         - Gives the images in the parsed wikitext
                 externallinks  - Gives the external links in the parsed wikitext
                 sections       - Gives the sections in the parsed wikitext
                 revid          - Adds the revision ID of the parsed page
                 displaytitle   - Adds the title of the parsed wikitext
                 headitems      - Gives items to put in the  of the page
                 headhtml       - Gives parsed  of the page
                 iwlinks        - Gives interwiki links in the parsed wikitext
                 wikitext       - Gives the original wikitext that was parsed
                Values (separate with '|'): text, langlinks, languageshtml,
                    categories, categorieshtml, links, templates, images,
                    externallinks, sections, revid, displaytitle, headitems,
                    headhtml, iwlinks, wikitext
                Default: text|langlinks|categories|links|templates|images|
                         externallinks|sections|revid|displaytitle
  pst         - Do a pre-save transform on the input before parsing it
                Ignored if page, pageid or oldid is used
  onlypst     - Do a pre-save transform (PST) on the input, but don't parse it
                Returns the same wikitext, after a PST has been applied. Ignored if
                    page, pageid or oldid is used
  uselang     - Which language to parse the request in
  section     - Only retrieve the content of this section number
  disablepp   - Disable the PP Report from the parser output
Example:
  api.php?action=parse&text={{Project:Sandbox}}

See the WikiMedia API help or the complete documentation.

It's not clear what you are hoping to have returned to you, an article or search results. Either way, to get results in xml, use format=xml.

To get a listing of articles that match a certain query, use the opensearch action. For example:
http://en.wikipedia.org/w/api.php?action=opensearch&search=MediaWiki&format=xml - View the results

From the section on action=opensearch in the API help:

* action=opensearch *
  Searches the wiki using the OpenSearch protocol

This module requires read rights
Parameters:
  search     - Search string
  limit      - Maximum amount of results to return
               No more than 100 (100 for bots) allowed
               Default: 10
  namespace  - Namespaces to search
               Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
                   13, 14, 15
               Maximum number of values 50 (500 for bots)
               Default: 0
  suggest    - Do nothing if $wgEnableOpenSearchSuggest is false
  format     - Output format defaults to JSON, with expanded XML optional.
               One value: json, jsonfm, xml, xmlfm
               Default: json
Example:
  api.php?action=opensearch&search=Te

To get the contents of a specific article, use the parse action. For example:
http://en.wikipedia.org/w/api.php?action=parse&page=MediaWiki&format=xml - View the results

From the section on action=parse in the API help:

* action=parse *
  Parses wikitext and returns parser output

This module requires read rights
Parameters:
  title       - Title of page the text belongs to
                Default: API
  text        - Wikitext to parse
  summary     - Summary to parse
  page        - Parse the content of this page. Cannot be used together with
                    text and title
  pageid      - Parse the content of this page. Overrides page
  redirects   - If the page or the pageid parameter is set to a redirect, resolve it
  oldid       - Parse the content of this revision. Overrides page and pageid
  prop        - Which pieces of information to get
                 text           - Gives the parsed text of the wikitext
                 langlinks      - Gives the language links in the parsed wikitext
                 categories     - Gives the categories in the parsed wikitext
                 categorieshtml - Gives the HTML version of the categories
                 languageshtml  - Gives the HTML version of the language links
                 links          - Gives the internal links in the parsed wikitext
                 templates      - Gives the templates in the parsed wikitext
                 images         - Gives the images in the parsed wikitext
                 externallinks  - Gives the external links in the parsed wikitext
                 sections       - Gives the sections in the parsed wikitext
                 revid          - Adds the revision ID of the parsed page
                 displaytitle   - Adds the title of the parsed wikitext
                 headitems      - Gives items to put in the  of the page
                 headhtml       - Gives parsed  of the page
                 iwlinks        - Gives interwiki links in the parsed wikitext
                 wikitext       - Gives the original wikitext that was parsed
                Values (separate with '|'): text, langlinks, languageshtml,
                    categories, categorieshtml, links, templates, images,
                    externallinks, sections, revid, displaytitle, headitems,
                    headhtml, iwlinks, wikitext
                Default: text|langlinks|categories|links|templates|images|
                         externallinks|sections|revid|displaytitle
  pst         - Do a pre-save transform on the input before parsing it
                Ignored if page, pageid or oldid is used
  onlypst     - Do a pre-save transform (PST) on the input, but don't parse it
                Returns the same wikitext, after a PST has been applied. Ignored if
                    page, pageid or oldid is used
  uselang     - Which language to parse the request in
  section     - Only retrieve the content of this section number
  disablepp   - Disable the PP Report from the parser output
Example:
  api.php?action=parse&text={{Project:Sandbox}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文