如何使用MediaWiki API在页面标题和内容中搜索文本?

时间:2012-09-03 17:23:19

标签: wikipedia-api mediawiki-api

我不确定它是否真的可以做,因为我只能找到如何搜索这样的标题:

/api.php?action=query&rvlimit=10&rvprop=content&format=xml&titles=searchterm

1 个答案:

答案 0 :(得分:5)

搜索包含“维基百科”一词的10个页面

api.php ? action=query & list=search & srsearch=wikipedia & srprop=timestamp

,结果是

<?xml version="1.0"?>
<api>
  <query>
    <searchinfo totalhits="40085" />
    <search>
      <p ns="0" title="Wikipedia" timestamp="2011-02-26T16:43:03Z" />
      <p ns="0" title="French Wikipedia" timestamp="2011-02-27T00:11:59Z" />
      <p ns="0" title="Main Page" timestamp="2011-01-19T19:49:11Z" />
      <p ns="0" title="Regent" timestamp="2011-02-24T03:45:02Z" />
      <p ns="0" title="Blocking of Wikipedia by the People&#039;s Republic of China" timestamp="2011-02-25T03:12:52Z" />
      <p ns="0" title="Nemzeti Bajnokság I" timestamp="2011-02-02T23:27:44Z" />
      <p ns="0" title="Teller–Ulam design" timestamp="2011-02-06T21:54:56Z" />
      <p ns="0" title="Norwegian Wikipedia" timestamp="2011-01-06T18:43:32Z" />
      <p ns="0" title="List of countries and outlying territories by total area" timestamp="2011-02-26T17:31:44Z" />
      <p ns="0" title="2009–2010 ISU Junior Grand Prix" timestamp="2011-02-19T04:24:52Z" />
    </search>
  </query>
  <query-continue>
    <search sroffset="10" />
  </query-continue>
</api>

更多here