我知道它urllib2可以在Google App Engine上作为Urlfetch的包装使用,如您所知,Universal Feedparser使用urllib2.
你知道在urllib2上设置超时的方法吗?urllib2上
的timeout参数是否已移植到Google App Engine版本上?
我对方法不感兴趣:
rssurldata = urlfetch(rssurl, deadline=..)
feedparser.parse(rssurldata)
Run Code Online (Sandbox Code Playgroud) 我当时正在为RSS供稿编写Python解析器脚本。我使用的是feedparser,但是,我仍然无法解析FeedBurner的供稿。如今谁需要FeedBurner?无论如何..
例如,我找不到解析方法
http://feeds.wired.com/wired/index
http://feeds2.feedburner.com/ziffdavis/pcmag
当我将它们放入feedparser库时,似乎无法正常工作。尝试将?fmt = xml或?format = xml放在URL的末尾,但仍然没有采用xml格式。
我是否需要使用诸如BeautifulSoup之类的html解析器来解析FeedBurner提要?最好是已经有一个python公共解析器或聚合器脚本可以处理这个问题了吗?
任何提示或帮助将不胜感激。
我正在尝试使用带有python的通用feedparser从Google新闻下载一组新闻(尝试进行一些自然语言处理).我对XML一无所知,我只是使用了如何使用feedparser的示例.问题是我在dict中找不到我从RSS提要获得的新闻内容只是标题.
我目前正在尝试使用的代码是:
import feedparser
url = 'http://news.google.com.br/news?pz=1&cf=all&ned=us&hl=en&output=rss'
# just some GNews feed - I'll use a specific search later
feed = feedparser.parse(url)
for post in feed.entries:
print post.title
print post.keys()
Run Code Online (Sandbox Code Playgroud)
我在这篇文章中得到的关键只是标题,摘要,日期等......没有内容.
这是谷歌新闻的一些问题还是我做错了什么?有办法吗?
rss文件如下所示,我想在media:group部分中获取内容。我检查了feedparser的文档,但似乎没有提及。怎么做?任何帮助表示赞赏。
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:ymusic="http://music.yahoo.com/rss/1.0/ymusic/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel>
<title>XYZ InfoX: Special hello </title>
<link>http://www1.XYZInfoX.com/learninghello/home</link>
<description>hello</description>
<language>en</language> <copyright />
<pubDate>Wed, 17 Mar 2010 08:50:06 GMT</pubDate>
<dc:creator />
<dc:date>2010-03-17T08:50:06Z</dc:date>
<dc:language>en</dc:language> <dc:rights />
<image>
<title>Voice of America</title>
<link>http://www1.XYZInfoX.com/learninghello</link>
<url>http://media.XYZInfoX.com/designimages/XYZRSSIcon.gif</url>
</image>
<item>
<title>Who Were the Deadliest Gunmen of the Wild West?</title>
<link>http://www1.XYZInfoX.com/learninghello/home/Deadliest-Gunmen-of-the-Wild-West-87826807.html</link>
<description> The story of two of them: "Killin'" Jim Miller was an outlaw, "Texas" John Slaughter was a lawman | EXPLORATIONS </description>
<pubDate>Wed, 17 Mar 2010 00:38:48 …Run Code Online (Sandbox Code Playgroud) 我有以下代码用于解析youtube feed并返回youtube movie id.我怎么能重写这个python 2.4兼容我认为不支持parse_qs功能?
YTSearchFeed = feedparser.parse("http://gdata.youtube.com" + path)
videos = []
for yt in YTSearchFeed.entries:
url_data = urlparse.urlparse(yt['link'])
query = urlparse.parse_qs(url_data[4])
id = query["v"][0]
videos.append(id)
Run Code Online (Sandbox Code Playgroud) 我需要在大多数情况下使用Python,Atom显示RSS-feeds.来自PHP,我可以通过$ entry-> link快速获得值,我发现lxml更精确,更快,虽然复杂.经过几个小时的探测,我得到了这个使用arstechnica-feed:
def GetRSSFeed(url):
out = []
feed = urllib.urlopen(url)
feed = etree.parse(feed)
feed = feed.getroot()
for element in feed.iterfind(".//item"):
meta = element.getchildren()
title = meta[0].text
link = meta[1].text
for subel in element.iterfind(".//description"):
desc = subel.text
entry = [title,link,desc]
out.append(entry)
return out
Run Code Online (Sandbox Code Playgroud)
这可以更轻松吗?如何直接访问标签?Feedparser通过一行代码完成工作!为什么?
我正在尝试编写一个python程序,它将抓取并显示自上次运行程序以来的任何rss更新.我正在使用feedparser并尝试使用etags并按照此处所述进行最后修改,但我的测试脚本似乎无法正常工作.
import feedparser
rsslist=["http://skottieyoung.tumblr.com/rss","http://mrjakeparker.com/feed/"]
for feed in rsslist:
print('--------'+feed+'-------')
d=feedparser.parse(feed)
print(len(d.entries))
if (len(d.entries) > 0):
etag=d.feed.get('etag','')
modified=d.get('modified',d.get('updated',d.entries[0].get('published','no modified,update or published fields present in rss')))
d2=feedparser.parse(feed,modified)
if (len(d2.entries) > 0):
etag2=d2.feed.get('etag','')
modified2=d2.get('updated',d.entries[0].get('published',''))
if (d2==d): #ideally we would never see this bc etags/last modified would prevent unnecessarily downloading what we all ready have.
print("Arrg these are the same")
Run Code Online (Sandbox Code Playgroud)
老实说,我不确定rss/xml技术是否已经改变了我在线使用的参考文献,或者我的代码是否有问题.
无论我在寻找有效使用rss feed的最佳解决方案.我正在寻找最小化带宽浪费,例如使用最后修改和etags字段的带宽浪费.
提前致谢.
我想安装feedparser.
这是尝试在Windows命令行中安装feedparser时发生的情况.
> python.exe setup.py install
running install
running bdist_egg
error: error in 'egg_base' option: 'feedparser does not exist or is not a directory
Run Code Online (Sandbox Code Playgroud)
我正在使用Python 2.7(feedparser网站声称"它在Python 2.4上一直运行到3.2").
我需要获取 RSS 提要的已发布字段,并且我需要知道时区是什么。我以 UTC 格式存储日期,并且我想要另一个字段来存储时区,以便我以后可以操纵日期时间。
我目前的代码如下:
for entry in feed['entries']:
if hasattr(entry, 'published'):
if isinstance(entry.published_parsed, struct_time):
dt = datetime(*entry.published_parsed[:-3])
Run Code Online (Sandbox Code Playgroud)
dt 的最终值是 UTC 中的正确日期时间,但我还需要获取原始时区。任何人都可以帮忙吗?
编辑:
为了将来参考,即使它不是我最初问题的一部分,如果您需要操作非标准时区(如 est),您需要根据您的规范制作一个转换表。感谢这个答案:Parsing date/time string with timezone abbreviated name in Python?
我正在使用 feedparser (Python) 从多个网站获取一些 RSS 条目。
如何使用 feedparser 执行异步请求?我的意思是,我想要获取一些 RSS 条目,但我不想等待响应。当我收到 feedparser 请求的响应时,应该调用回调函数。在请求之后(可能在回复之前)我想做一些计算。
谢谢大家,雨果
feedparser ×10
python ×9
rss ×5
asynchronous ×1
atom-feed ×1
datetime ×1
deprecated ×1
django ×1
feeds ×1
google-news ×1
installation ×1
lxml ×1
python-2.4 ×1
timezone ×1
urlfetch ×1
urllib2 ×1
xml-parsing ×1