我有以下 API 可以從中提取數(shù)據(jù): https://www.business- humanrights.org/en/api/internal/explore/?format=json&search=nike我已經(jīng)使用 json 提取了 API 結(jié)果(見下文),但 API 的結(jié)構(gòu)似乎相當(dāng)復(fù)雜,我不明白如何提取與我相關(guān)的信息并將其存儲到 pandas 數(shù)據(jù)框中。我感興趣的信息是以下鍵的值“translated_title” “回溯日期” “translated_abstract” “translated_url”r = requests.get("https://www.business-humanrights.org/en/api/internal/explore/?format=json&search=nike") rjson = r.json() users_locs = [webPage for webPage in rjson['results']] users_locs更一般地說,如果我能指出如何從字典中的列表中的列表中提取數(shù)據(jù)的邏輯,等等,那就太好了。我的預(yù)期輸出是新聞級別的數(shù)據(jù)集,其中我為每一行報告翻譯后的標(biāo)題、翻譯后的摘要和回溯日期。請參見以下結(jié)構(gòu):df = pd.DataFrame([{"translated_title" : "Chine : La pression augmente contre Nike, Apple et d’autres à mesure que le boycott lié aux allégations de travail forcé s’intensifie", "translated_abstract":'..', "backdate": "2020-07-24"}, {"translated_title" : "..", "translated_abstract":'..', "backdate": ".."}])謝謝!
使用 Python 從具有不同級別的嵌套列表和字典的 json 中提取數(shù)據(jù)
30秒到達戰(zhàn)場
2023-06-27 18:11:40