RSS提要仅在今天使用Python进行抓取
也许有人能帮忙。我制作了一个python脚本来获取RSS提要。现在,我的目标是,我感兴趣的RSS提要只是今天。我已经成功了,但当我尝试某些链接时,它却不能(我认为日期的格式有问题)。 在此链接上运行的我的脚本: 但是,当我使用此链接时,我的脚本错误: 这是我的密码RSS提要仅在今天使用Python进行抓取,python,datetime,rss,Python,Datetime,Rss,也许有人能帮忙。我制作了一个python脚本来获取RSS提要。现在,我的目标是,我感兴趣的RSS提要只是今天。我已经成功了,但当我尝试某些链接时,它却不能(我认为日期的格式有问题)。 在此链接上运行的我的脚本: 但是,当我使用此链接时,我的脚本错误: 这是我的密码 import feedparser import datetime dgtw = feedparser.parse('http://ax.itunes.apple.com/WebObjects/MZStoreServices.wo
import feedparser
import datetime
dgtw = feedparser.parse('http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=25/xml')
n = len(dgtw['entries'])
today = datetime.datetime.now().date()
yesterday = today - datetime.timedelta(days=1)
entries = []
for x in range(0,n):
entry = dgtw.entries[x]
date = dgtw.entries[x].published
date = datetime.datetime.strptime(date[5:16],'%d %b %Y').date()
if date == today:
entries.append(entry)
print("Entries posted today:",len(entries))
print("Entries today:")
for el in entries:
print(el['title'])
print(el['published'])
For my error :
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'published'
多谢各位