I am trying to access images and extracts on a Wikipedia page via the API.

According to the documentation, the way to do this is to add prop=images to the request URL.

api.php?action=query&titles=Albert%20Einstein&prop=images

But if I combine extracts and images

api.php?action=query&titles=Albert%20Einstein&prop=images&extracts

I get the following response

parsed_response={"warnings"=>{"main"=>{"*"=>"Unrecognized parameter: 'images'"}}

Each of these works individually. Combining other props (e.g., extracts&exintro&explaintext&redirects) also works.

Why can't I get extracts and images via a single API request?

有帮助吗?

解决方案

It should be | in the place of &:

api.php?action=query&titles=Albert%20Einstein&prop=images|extracts


extracts&exintro&explaintext happens to work, because exintro and explaintext are not properties, but extra parameters that can be added when using prop=extracts. To combine them all, use

api.php?action=query&titles=Albert%20Einstein&prop=images|extracts&exintro&explaintext

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top