lesslessless.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:rss-reader-lesslessless 作者: Backup08 项目源码 文件源码
def getRss(self, url):       
        d = feedparser.parse(url) 

        os.system("rm -r /tmp/rss.html")
        with open('/tmp/rss.html', 'a') as the_file:
            the_file.write('<!DOCTYPE html><html><head><meta')
            the_file.write('charset="utf-8"><meta')
            the_file.write('name="viewport" content="width=device-width, initial-scale=1"><title>' +  d['feed']['title'] + '</')
            the_file.write('title><style type="text/css">body{margin:40px auto;')
            the_file.write('max-width:650px;line-height:1.6;font-size:18px;color:#444;padding:0')
            the_file.write('10px}h1,h2,h3{line-height:1.2}a{text-decoration: none; color:black;};</style></head><body><!-- RSS Feed --><header><h1>') 
            the_file.write( d['feed']['title'] + '</h1>')
            #the_file.write('<aside>' + '-' + '</aside>')
            the_file.write('</header><hr noshade>')
            the_file.write('<p>')

            for post in d.entries:
                the_file.write('<a href="' + post.link.encode('ascii', 'ignore') + '">' + post.title.encode('ascii', 'ignore') + "</a><br><br>")


            the_file.write('</p>')
            the_file.write('</body>')

            url = QUrl( 'file:///' + 'tmp' + '/rss.html' )
            self.webView.load(url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号