是否有使用请求和熊猫按日期对事物进行排序的方法?

问题描述 投票:0回答:1

就像在主题中一样。我的代码如下所示。一切正常,但字典似乎被剪断了。最新的CVE是从2016年开始...而不是2020年。就像下面的屏幕一样。这是什么问题我怎样才能达到2020年的CVE? Pycharm不能加载其余的吗?我尝试在cmd中运行它,但结果更糟,它在2014年被削减。我该怎么办?

import pandas as pd
import requests

keyword = 'oracle'
url = 'https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword={}'.format(keyword)
html_data = requests.get(url).text

df = pd.read_html(html_data)
data = df[2].to_dict(orient='records')

for dict in data:
    for key in dict:
        print(key, dict[key])

enter image description here

这是在cve.mitre.org上的样子

enter image description here

python pandas python-requests
1个回答
0
投票

您可以像这样打印2020个:

for d in data:
    if d['Name'].split('-')[1] == '2020':
        print(d['Name'])
        print(d['Description'])
© www.soinside.com 2019 - 2024. All rights reserved.