Using PHP, how do I get the first paragraph of a Wikipedia article with the MediaWiki API?

前端 未结 2 1527
轻奢々
轻奢々 2021-01-26 02:36

How do I use PHP to get the first paragraph of any article from Wikipedia through their MediaWiki API?

I am open to all suggestions. Most probably CUR

2条回答
  •  爱一瞬间的悲伤
    2021-01-26 03:19

    You can use the API as so:

    http://en.wikipedia.org/w/api.php?action=parse&page=Stack_overflow&format=xml&prop=text§ion=0
    

    This will return an xml file with structure:

    
    
      
        Text you wanted goes here
      
    
    

    Note the variables: page=Article_Title_Goes_Here format=xml prop=text

提交回复
热议问题