Freezethewind / -XML-Reader-Lofter-Data-Backup

XML readers for xml files of LOFTER users data
57 stars 4 forks source link

评论区回复时间显示的是时间戳 #2

Open shutongX opened 4 years ago

shutongX commented 4 years ago
cList = item.getElementsByTagName("commentList")
    if (len(cList) > 0) :
        comList = cList[0].getElementsByTagName('comment')
        comments = []
        for comm in comList:
            pubid = comm.getElementsByTagName("publisherUserId")[0].childNodes[0].data
            pubnick = comm.getElementsByTagName("publisherNick")[0].childNodes[0].data
            comcon = comm.getElementsByTagName("content")[0].childNodes[0].data
            comtime = comm.getElementsByTagName("publishTime")[0].childNodes[0].data
            comtime_new = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(float(int(comtime)/1000)))
            repid = comm.getElementsByTagName("replyToUserId")[0].childNodes[0].data
            comments.append({"pubid":pubid, "pubnick":pubnick, "comcon":comcon, "comtime":comtime_new, "repid":repid})
    else :
        comments = []

如上,转换一下就行

Freezethewind commented 4 years ago

好的!谢谢!这个评论时间戳我忘记转换了,白天会修改

---原始邮件--- 发件人: "谢子昆"<notifications@github.com> 发送时间: 2020年6月13日(周六) 凌晨0:13 收件人: "Freezethewind/-XML-Reader-Lofter-Data-Backup"<-XML-Reader-Lofter-Data-Backup@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: [Freezethewind/-XML-Reader-Lofter-Data-Backup] 评论区回复时间显示的是时间戳 (#2)

cList = item.getElementsByTagName("commentList") if (len(cList) > 0) : comList = cList[0].getElementsByTagName('comment') comments = [] for comm in comList: pubid = comm.getElementsByTagName("publisherUserId")[0].childNodes[0].data pubnick = comm.getElementsByTagName("publisherNick")[0].childNodes[0].data comcon = comm.getElementsByTagName("content")[0].childNodes[0].data comtime = comm.getElementsByTagName("publishTime")[0].childNodes[0].data comtime_new = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(float(int(comtime)/1000))) repid = comm.getElementsByTagName("replyToUserId")[0].childNodes[0].data comments.append({"pubid":pubid, "pubnick":pubnick, "comcon":comcon, "comtime":comtime_new, "repid":repid}) else : comments = []
如上,转换一下就行

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.