我有一个代码,我得到一个字典,有几个相同的标题和描述键,我如何获取所有标题值和所有描述值?
from newsapi import NewsApiClient
titles=[]
descriptions=[]
newsapi = NewsApiClient(api_key='f708ba26461f4990adfcc0eb76a72172')
top_headlines = newsapi.get_top_headlines(category='sports',language='ru')
title=top_headlines.get('title')
print(title)
print(top_headlines)
字典示例:
{'status': 'ok', 'totalResults': 68, 'articles': [{'source': {'id': None, 'name': 'Sports.ru'}, 'author': 'Любовь Энина', 'title': 'Тартакову отстранили от работы на «Матч ТВ» после критики шоу «Есть тема» о Касаткиной и Рублеве - Sports.ru', 'description': '«Матч ТВ» отстранил от эфира Софью Тартакову за критику в адрес шоу «Есть тема».', 'url': 'https://www.sports.ru/tennis/1110551536-tartakovu-otstranili-ot-raboty-na-match-tv-posle-kritiki-shou-est-tema.html', 'urlToImage': 'https://www.sports.ru/dynamic_images/news/111/055/153/6/share/5d6bf5.jpg', 'publishedAt': '2022-07-20T14:16:18Z', 'content': '« » « ».\r\n. : « - , , 5- . « », ».\r\n « » .\r\n« , , .\r\n , .\r\n , , , , .\r\n , . », -.'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Александр Фролов', 'title': 'Никита Цзю — Бен Хорн. Никита перенёс стоячий нокдаун, но выжил. Есть победа! Live! - Чемпионат', 'description': 'Старший брат Тимофей порадовал великолепным русским языком!', 'url': 'https://www.championat.com/boxing/article-4761291-nikita-czyu-ben-horn-onlajn-translyaciya-boya-syn-kosti-czyu-boj-czyu-i-horna-gde-smotret.html', 'urlToImage': 'https://img.championat.com/news/social/d/6f/4761291.jpg', 'publishedAt': '2022-07-20T13:43:13Z', 'content': '. . , . , ?! !!! , ? .\r\n5 . , . , . , , : « », . . !!!\r\n. : «, !!!» , . , . .\r\n. , , . , . , . .\r\n. . . . . . , ( , ), . , . \r\n, . , «Seven Nation Army» The White Stripes . . , - . .\r\n( ), ? 32- 4-4.… [+125 chars]'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Михаил Чесалин', 'title': 'Магнус Карлсен — величайший! Его отказ играть с Яном Непомнящим это только подтверждает - Чемпионат', 'description': 'Поступил как настоящий король.', 'url': 'https://www.championat.com/other/article-4761521-pochemu-otkaz-magnusa-karlsena-igrat-s-yanom-nepomnyaschim-eto-postupok-kotoryj-vojdyot-v-istoriyu-mirovogo-sporta.html', 'urlToImage': 'https://img.championat.com/news/social/5/72/4761521.jpg', 'publishedAt': '2022-07-20T13:00:14Z', 'content': '20 , , , , 2023 . 2021- , , . .\r\n . 1975 . , . .\r\n, , , . - . .\r\n , , . , , . ( ) ( , ). 2013-, . .\r\n , . , , . , , , , , . .\r\n: fide.com\r\n.\r\n? , . , , , .\r\n , . , , , . , .\r\n, , . , , . . , , , .\r\n … [+64 chars]'}, {'source': {'id': None, 'name': 'Sportrbc.ru'}, 'author': None, 'title': 'В IIHF заявили, что время для контактов с Россией «еще не пришло» - РБК Спорт', 'description': 'По словам генсека IIHF Нурминена, который занял должность в начале июня, никаких контактов с ФХР у него пока не было. Сборные России с февраля отстранены от международных соревнований, ранее сообщалось, что мужская команда пропустит ЧМ-2023', 'url': 'https://sportrbc.ru/news/62d79ff39a794743c7cb2b39', 'urlToImage': 'https://s0.rbk.ru/v6_top_pics/media/img/2/97/756582989830972.jpg', 'publishedAt': '2022-07-20T12:39:50Z', 'content': ''}, {'source': {'id': None, 'name': 'Sportrbc.ru'}, 'author': None, 'title': '«Матч ТВ» узнал о проблемной допинг-пробе одного из лучших атлетов России - РБК Спорт', 'description': 'По данным телеканала, прыгун в высоту Александр Асанов сдал положительную пробу на запрещенный диуретик, за который в 2017 году отстраняли хоккеиста Даниса Зарипова', 'url': 'https://sportrbc.ru/news/62d7ede49a79476940d33e77', 'urlToImage': 'https://s0.rbk.ru/v6_top_pics/media/img/7/84/756583187712847.jpg', 'publishedAt': '2022-07-20T12:13:42Z', 'content': '- , « ».\r\n - , 2021 , , .\r\n (). - .\r\n (2020) (2019) , 2021 .\r\n, - 2021 .\r\n (World Athletics) 2021 , ( ) ( ).\r\n .\r\n 2017 - , , , .'}, {'source': {'id': None, 'name': 'Teleprogramma.pro'}, 'author': 'Алексей Заякин', 'title': 'Губерниев вспомнил пословицу, говоря о возможной смене гражданства Касаткиной и Рублевым - TELEPROGRAMMA.PRO', 'description': 'Как отметил спортивный комментатор, страна должна быть готова к этому.', 'url': 'https://teleprogramma.pro/news/guberniev-vspomnil-poslovicu-govorya-o-vozmozhnoy-smene-grazhdanstva-kasatkinoy-i-rublevym_nid4324335_au73659au73605_cr73659cr73605#article', 'urlToImage': 'https://teleprogramma.pro/sites/default/files/styles/post_850x666/public/text-images/2022-07/guberniev1_1658315349_1658315525.jpg?itok=fbxY1W7a', 'publishedAt': '2022-07-20T11:12:42Z', 'content': '.\xa0: Global Look Press\r\nTeleprogramma.pro , .\r\n, - . .'}, {'source': {'id': None, 'name': 'Sports.ru'}, 'author': 'Алексей Белоус', 'title': 'Рафинья Диас: «Барселона» лучше, чем «Реал» - Sports.ru', 'description': 'Вингер «Барселоны» Рафинья Диас считает, что его команда лучше, чем «Реал».', 'url': 'https://www.sports.ru/football/1110547065-rafinya-dias-barselona-luchshe-chem-real-na-moj-vzglyad.html', 'urlToImage': 'https://www.sports.ru/dynamic_images/news/111/054/706/5/share/3d3932.jpg', 'publishedAt': '2022-07-20T11:07:00Z', 'content': '«» , , «».\xa0\r\n« , , .\r\n . , , , «».\r\n «» . . [«»] », .\xa0\r\n24 «» «» .'}, {'source': {'id': None, 'name': 'Sports.ru'}, 'author': 'Александр Митрофанов', 'title': '«Рома» анонсировала трансфер Дибалы - Sports.ru', 'description': 'Бывший форвард «Ювентуса» Пауло Дибала переходит в «Рому».', 'url': 'https://www.sports.ru/football/1110548624-roma-anonsirovala-transfer-dibaly.html', 'urlToImage': 'https://www.sports.ru/dynamic_images/news/111/054/862/4/share/32a72b.jpg', 'publishedAt': '2022-07-20T10:47:13Z', 'content': '«» «».\r\n 28- , \xa0.\r\n, «» 3- 6 .\r\n «» «»\xa0(2:3).\r\n \xa0.\r\n: «»'}, {'source': {'id': None, 'name': 'Livesport.ru'}, 'author': 'LiveSport.Ru', 'title': 'Ференцварош — Слован. Прогноз и ставка за 2.54 - LiveSport.Ru', 'description': 'Ференцварош — Слован. Прогноз, ставка, фрибет. Сегодня в 21:00. Сможет ли «Ференцварош» Черчесова разгромить «Слован»?', 'url': 'https://www.livesport.ru/tips/football/2022/07/20/ferencvaros_slovan-bratislava/', 'urlToImage': 'https://cdn.livesport.ru/l/tips/football/2022/07/20/ferencvaros_slovan-bratislava/picture--original.jpg?1658156607', 'publishedAt': '2022-07-20T10:36:36Z', 'content': '«» «»?\r\n«» «» . 20 , 21:00 . «» «»: , , , .\r\n«»\r\n«» . «».\r\n0:0, 5:1.\r\n. 20- «» , . \r\n«» , « ».\r\n«»\r\n«» «» . «», .\r\n0:0, . \r\n«» . , .\r\n«» , « » (1:2).\r\n«» 1.53, 3.96, «» 6.10.\r\n, «», «».\r\n, .\r\n«» (-1,… [+18 chars]'}, {'source': {'id': None, 'name': 'Sportbox.ru'}, 'author': None, 'title': 'Кавасаки Фронтале - ПСЖ (1:2) 20 июля. Контрольные матчи. 2022-23. Протокол матча - news.Sportbox.ru', 'description': 'Онлайн трансляция матча Кавасаки Фронтале (Кавасаки) - ПСЖ (Париж), Контрольные матчи. 2022-23, 20 июля', 'url': 'https://news.sportbox.ru/Vidy_sporta/Futbol/stats/turnir_19971/game_1380842845', 'urlToImage': 'https://s-cdn.sportbox.ru/images/shares/1200x600/game/ad/1380842845.jpg', 'publishedAt': '2022-07-20T10:30:00Z', 'content': '© « » 2007 2022.16 \r\n «www.sportbox.ru» \xa0 \xa0 , \xa0 ().\r\n №\xa077-72613 \xa004.04.2018\r\n — www.sportbox.ru\r\n () «www.sportbox.ru»: « »\r\n «www.sportbox.ru»: ..\r\n «www.sportbox.ru»: +7 (495) 653 8419\r\n «www.spor… [+27 chars]'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Диана Валавичюте', 'title': 'Дортмундская «Боруссия» сделала предложение Суаресу в связи с болезнью Аллера - Чемпионат', 'description': 'Уругвайский нападающий Луис Суарес может продолжить карьеру в дортмундской «Боруссии», сообщает Sky Germany.', 'url': 'https://www.championat.com/football/news-4761387-dortmundskaya-borussiya-sdelala-predlozhenie-suaresu-v-svyazi-s-boleznyu-allera.html', 'urlToImage': 'https://img.championat.com/news2/social/6/9a/4761387.jpg', 'publishedAt': '2022-07-20T09:53:26Z', 'content': '«», Sky Germany. \r\n, 35- , . «» . 28- . \r\n«», 30 . «», «», «», «» «». 2007 .'}, {'source': {'id': None, 'name': 'Sportrbc.ru'}, 'author': None, 'title': 'Шубенков ответил украинке на слова «русские ничего не понимают» - РБК Спорт', 'description': 'Шубенков ответил на критику Магучих в адрес Ласицкене и других россиян и признался, что ушел из соцсетей из-за «пересказывавшей телевизор» украинской легкоатлетки', 'url': 'https://sportrbc.ru/news/62d7c92d9a794756924a6d1e', 'urlToImage': 'https://s0.rbk.ru/v6_top_pics/media/img/6/46/756583102413466.jpg', 'publishedAt': '2022-07-20T09:51:13Z', 'content': '2015 Metaratings, \xa0 , .\r\n 19 NRK, , .\r\n« : « () ». 20 , ? , . () . , -. , , »,\xa0— .\r\n , - .\r\n« , - , , . -- . . »,\xa0— .\r\n , 2015 .\r\n 9 , , « » « » .\r\n .\r\n.\r\n 2,02 , .'}, {'source': {'id': None, 'name': 'F1news.ru'}, 'author': 'Александр Романов', 'title': 'На Игора Драйв представлена новая конфигурация трассы - Формула 1 на F1News.Ru', 'description': 'На автодроме Игора Драйв состоялось официальное открытие новой конфигурации трассы, способной принимать соревнования самого высокого уровня...', 'url': 'https://www.f1news.ru/news/autosport-162002.html', 'urlToImage': 'https://cdn.f1ne.ws/userfiles/162002.jpg', 'publishedAt': '2022-07-20T09:00:00Z', 'content': '̆, 50 -, ̆ , .\r\n , , ̆ , ̆ «».\r\n 2021 , ̆ , FIA, FIM ̆ .\r\n ̆ , 5183 ( 4086 ). 20,5 , 15 16 12,5%.\r\n , 1 2022 325 /, 1 . 22 .\r\n65 , , . , 30-35 , .\r\n : . ̆ ̆.\r\n, , « »: « Grade A, FIA, FIM, , . , 1, M… [+344 chars]'}, {'source': {'id': None, 'name': 'Sport-express.ru'}, 'author': 'Андрей Кузичев', 'title': '«У него нет потолка». В Парагвае не жалеют комплиментов для новичка «Динамо» - Спорт-Экспресс', 'description': 'Рассказываем о\xa0южноамериканце, который в\xa0ближайшие дни подпишет контракт с\xa0бело-голубыми.', 'url': 'https://www.sport-express.ru/football/rfpl/reviews/roberto-fernandes-yuzhnoamerikanec-kotoryy-v-blizhayshie-dni-podpishet-kontrakt-s-dinamo-1951768/', 'urlToImage': 'https://ss.sport-express.ru/userfiles/materials/180/1801588/large.jpg', 'publishedAt': '2022-07-20T08:53:35Z', 'content': '«» , \xa0 \xa0 «» . , , \xa0, \xa0 22- . \xa0 \xa0, \xa0 \xa0 .\r\n , - , «», \xa0 , \xa0 \xa0 «» \xa0 « ». \xa0 , \xa0 , \xa0 , .\r\n«\xa0 \xa0, \xa0 \xa0. \xa0 «», »,\xa0 \xa0D10.\r\n\xa0 \xa0 , \xa0 \xa0 \xa0 . «\xa0, \xa0 , \xa0 , \xa0\xa0 \xa0, \xa0 \xa0, \xa0 . \xa0 . \xa0 , \xa0 \xa0, , , \xa0\xa0 . \xa0\xa0 \xa0\xa0, \xa0 - , \xa0 »,\xa0 \xa0 \xa0 … [+428 chars]'}, {'source': {'id': None, 'name': 'Sportbox.ru'}, 'author': 'Сергей Почежирцев', 'title': 'Россиянка прыгнула выше, но золото чемпионата мира отдали американке. И где справедливость? - news.Sportbox.ru', 'description': 'Анжелика Сидорова совершила потрясающую попытку, но на пьедестале в Юджине её не оказалось.', 'url': 'https://news.sportbox.ru/Vidy_sporta/light_attletics/spbnews_NI1636171_Rossijanka_prygnula_vyshe_no_zoloto_chempionata_mira_otdali_amerikanke_I_gde_spravedlivost', 'urlToImage': 'https://s-cdn.sportbox.ru/images/shares/1200x600/node/30/1636171.jpg', 'publishedAt': '2022-07-20T08:45:05Z', 'content': '© « » 2007 2022.16 \r\n «www.sportbox.ru» \xa0 \xa0 , \xa0 ().\r\n №\xa077-72613 \xa004.04.2018\r\n — www.sportbox.ru\r\n () «www.sportbox.ru»: « »\r\n «www.sportbox.ru»: ..\r\n «www.sportbox.ru»: +7 (495) 653 8419\r\n «www.spor… [+27 chars]'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Денис Шумаков', 'title': 'Марио Фернандес согласовал условия контракта с «Сантосом» - Чемпионат', 'description': 'Правый защитник ЦСКА Марио Фернандес, в мае приостановивший карьеру, близок к заключению контракта с бразильским «Сантосом», утверждает TNT Sports.', 'url': 'https://www.championat.com/football/news-4761309-mario-fernandes-soglasoval-usloviya-kontrakta-s-santosom.html', 'urlToImage': 'https://img.championat.com/news2/social/b/2f/4761309.jpg', 'publishedAt': '2022-07-20T08:43:45Z', 'content': ', , «», TNT Sports.\r\n, , . , 2024 .\r\n- 10 . 329 , 11 47 . 2016 33 , . 2018 , .'}, {'source': {'id': None, 'name': 'F1news.ru'}, 'author': 'Михаил Смирнов', 'title': 'Марко: Приход Макса – переломный момент для Риккардо - Формула 1 на F1News.Ru', 'description': 'Консультант Red Bull Хельмут Марко считает, что приход в команду Макса Ферстаппена оказалось переломным моментом в карьере Ланиэля Риккардо.', 'url': 'https://www.f1news.ru/news/f1-162007.html', 'urlToImage': 'https://cdn.f1ne.ws/userfiles/marko/162007.jpg', 'publishedAt': '2022-07-20T08:40:00Z', 'content': 'Red Bull Racing , . Red Bull , .\r\n : « . , , , . , .\r\n Red Bull Racing . , . .\r\n , , . , . ! , , ».'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Александр Насонов', 'title': 'Украинец Сергей Стаховский обратился к Дарье Касаткиной, которая совершила каминг-аут - Чемпионат', 'description': 'Бывший украинский теннисист Сергей Стаховский обратился к 12-й ракетке мира, российской теннисистке Дарье Касаткиной, которая призналась в нетрадиционной ориентации. После признания Касаткина выложила совместную фотографию с серебряным призёром зимних Олимпий…', 'url': 'https://www.championat.com/tennis/news-4761305-ukrainec-sergej-stahovskij-obratilsya-k-dare-kasatkinoj-kotoraya-sovershila-kaming-aut.html', 'urlToImage': 'https://img.championat.com/news2/social/7/26/4761305.jpg', 'publishedAt': '2022-07-20T08:35:26Z', 'content': '12- , , . 2018 .\r\n , «» .\r\n« . , », «», .\r\n 25- , . .\r\n :'}, {'source': {'id': None, 'name': 'Sportmail.ru'}, 'author': 'Спорт Mail.ru', 'title': 'Филатов считает, что критика ФШР со стороны Карякина связана с эмоциональным срывом - Спорт Mail.ru', 'description': 'Ранее российский гроссмейстер в своем телеграм-канале раскритиковал руководство Федерации шахмат России за недостаточное количество крупных турниров в стране.', 'url': 'https://sportmail.ru/news/chess/52262369/', 'urlToImage': 'https://news.mail.ru/social_preview/52262369/sport/?time=8b1a3f21feda12ccfc36b74b2d854bd1', 'publishedAt': '2022-07-20T08:31:56Z', 'content': ', 20\xa0. /. /. \xa0 \xa0 \xa0— \xa0 . \xa0 . \xa0 - \xa0 \xa0.«\xa0\xa0\xa0 , \xa0 \xa0 \xa0 . \xa0 ,\xa0— . —\xa0- , \xa0 \xa0 , \xa0, , \xa0.\r\n\xa0\xa0\xa0 \xa0\xa0 \xa0 , \xa0 \xa0 , \xa0 \xa0 \xa0, . , \xa0 “ ”. , \xa0 \xa0, , \xa0 ».\r\n\xa0 \xa017\xa0 \xa04\xa0 , \xa0 \xa0 . . \xa0, \xa0 \xa0 \xa0 -\xa0 \xa0. 32 , \xa0 2015 , \xa0 (2012) \xa0 (2016). … [+14 chars]'}, {'source': {'id': None, 'name': 'Championat.com'}, 'author': 'Денис Шумаков', 'title': 'Магомед Оздоев: мой приоритет — переход в европейский клуб - Чемпионат', 'description': 'Бывший полузащитник петербургского «Зенита» Магомед Оздоев рассказал о возможных вариантах продолжения своей карьеры.', 'url': 'https://www.championat.com/football/news-4761251-magomed-ozdoev-moj-prioritet-perehod-v-evropejskij-klub.html', 'urlToImage': 'https://img.championat.com/news2/social/a/62/4761251.jpg', 'publishedAt': '2022-07-20T07:41:43Z', 'content': '«» .\r\n« , , . , - . [] , - . \r\n, . , - . , », - « ».\r\n313 , 22 27 . , 35 .'}]}
你有一本字典,里面有一个列表,里面还有更多的字典。你可以像这样解析它:
pip install jmespath