通过Google Reader访问RSS

Tuesday, June 29, 2010

今天发现原来写的脚本不能正常工作了 所以决定重写一下,
找到一个简单版的gauth的脚本 代码片段:

# encoding: utf-8
"""
Created by Eric Lo (lxneng@gmail.com. http://lxneng.com/) on 2010-06-29.
"""

from gauth import build_opener

class GReader(object):
    def __init__(self, username, password):
        self.login(username, password)

    def login(self, username, password):
        self.username = username
        self.password = password
        self.opener = build_opener(username,password)

    def get_url(self, url):
        return self.opener.open(url, timeout=20).read()

#gr = GReader(username='xxxxxxxx@gmail.com', reader_password='password')
#gr.get_page(url = 'http://www.google.com/reader/atom/feed/http://news.163.com/special/00011K6L/rss_newstop.xml?n=100')

比原来简单清晰多了, 代码是越写越少的!~

This entry was tagged Python

comments powered by Disqus

© 2009-2013 lxneng.com. All rights reserved. Powered by Pyramid

go to Top