Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RSS提要仅在今天使用Python进行抓取_Python_Datetime_Rss - Fatal编程技术网

RSS提要仅在今天使用Python进行抓取

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

也许有人能帮忙。我制作了一个python脚本来获取RSS提要。现在,我的目标是,我感兴趣的RSS提要只是今天。我已经成功了,但当我尝试某些链接时,它却不能(我认为日期的格式有问题)。 在此链接上运行的我的脚本: 但是,当我使用此链接时,我的脚本错误: 这是我的密码

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'
多谢各位