我正在尝试从Wikipedia-api获取时间戳并将其拆分为(y-m-d)格式,但仍然找不到解决方法。
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php?"
PARAMS = {
'action':'query','prop':'revisions','rvlimit':'1','rvprop':"timestamp|user|comment|content",'rvdir': 'newer','format':'json','titles': 'Brno'
}
R = S.get(url=URL,params=PARAMS)
DATA = R.json()
PAGES = DATA["query"]["pages"]
print(PAGES)
for page in PAGES:
print(page)
在这里输出:
{'57575': {'pageid': 57575,'ns': 0,'title': 'Brno','revisions': [{'user': 'Jeronimo','timestamp': '2002-06-16T13:40:19Z','contentformat': 'text/x-wiki','contentmodel': 'wikitext','comment': '*','*': "'''Brno''' (population 390,000,[[German language|German]]: ''Brünn'') is the second largest city of the [[Czech Republic]],located in the southeast of the country,at the confluence of the [[Svitava]] and [[Svratka]] rivers.\r\n"}]}}
57575