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

前端 未结 2 1529
轻奢々
轻奢々 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:33

    I would use file_get_contents('http://wikipedia.com/'.$rest_of_url)

    Then just use string parsing to select everything form

    to

    http://php.net/manual/en/function.substr.php

提交回复
热议问题