ищу API википедии, которая может дать мне свою статью в XML - PullRequest
2 голосов
/ 18 января 2012

Я ищу API википедии, которая может дать мне статью (без изображения) на соответствующий запрос.Я видел википедию API, используемую с actions=opensearch и query=search.Пожалуйста, скажите мне, какой из них правильный или если есть какие-либо другие action, которые я должен использовать.

1 Ответ

4 голосов
/ 19 января 2012

См. Справка WikiMedia API или полная документация .

Непонятно, что вы надеетесь вернуть вам, статью или результаты поиска. В любом случае, чтобы получить результаты в формате xml, используйте format=xml.

Чтобы получить список статей, соответствующих определенному запросу, используйте действие opensearch . Например:
http://en.wikipedia.org/w/api.php?action=opensearch&search=MediaWiki&format=xml - Посмотреть результаты

Из раздела action=opensearch в справке 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

1025 *
*

Чтобы получить содержимое определенной статьи, используйте действие parse . Например:
http://en.wikipedia.org/w/api.php?action=parse&page=MediaWiki&format=xml - Просмотр результатов

Из раздела action=parse в справке 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}}
...