В качестве сайта для парсинга выбрал Википедию.
Вот код:
import requests
import json
response = requests.get(url="https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Apple")
info = json.loads(response.text)
В info записывается следующая информация:
{"batchcomplete":"",
"query":{
"pages":{
"18978754":{
"pageid":18978754,
"ns":0,
"title":"Apple",
"extract":"An apple is a round, edible fruit produced by an apple tree (Malus domestica). Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus. The tree originated in Central Asia, where its wild ancestor, Malus sieversii, is still found. Apples have been grown for thousands of years in Asia and Europe and were introduced to North America by European colonists. Apples have religious and mythological significance in many cultures, including Norse, Greek, and European Christian tradition.\nApples grown from seed tend to be very different from those of their parents, and the resultant fruit frequently lacks desired characteristics. Generally, apple cultivars are propagated by clonal grafting onto rootstocks. Apple trees grown without rootstocks tend to be larger and much slower to fruit after planting. Rootstocks are used to control the speed of growth and the size of the resulting tree, allowing for easier harvesting.\nThere are more than 7,500 cultivars of apples. Different cultivars are bred for various tastes and uses, including cooking, eating raw, and cider production. Trees and fruit are prone to fungal, bacterial, and pest problems, which can be controlled by a number of organic and non-organic means. In 2010, the fruit's genome was sequenced as part of research on disease control and selective breeding in apple production.\nWorldwide production of apples in 2021 was 93 million tonnes, with China accounting for nearly half of the total."
}
}
}
}
Мне нужно вывести информацию из "extract". Но объект "18978754" для каждой статьи представляет разное число (т.е. способом print(info["query"]["pages"]["18978754"]["extract"]) не получится). Вопрос такой: Как получить доступ к свойству объекта "extract" не зная его название?