From 065707719193ce6cbaa6df3e59369c963ed32297 Mon Sep 17 00:00:00 2001 From: pictuga Date: Wed, 25 Sep 2013 12:37:14 +0200 Subject: [PATCH] Add support for twitter Grabs "feed" from the html page, clips tweet and article together. --- feedify.ini | 11 +++++++++++ morss.py | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 feedify.ini diff --git a/feedify.ini b/feedify.ini new file mode 100644 index 0000000..0940c28 --- /dev/null +++ b/feedify.ini @@ -0,0 +1,11 @@ +[twitter] +path= + http://twitter.com/* + https://twitter.com/* + +title= (//strong[class=search-query]|//span[class=screen-name])/text() +items= //div[class=tweet] + +item_title= (.//span[class=username]//text())[2] +item_link= .//a[class=details]/@href +item_content= .//p[class=tweet-text] diff --git a/morss.py b/morss.py index dd6bcfb..fd82fbf 100644 --- a/morss.py +++ b/morss.py @@ -304,6 +304,14 @@ def Fill(item, cache, feedurl='/', fast=False, clip=False): link = item.link + # twitter + if urlparse.urlparse(item.link).netloc == 'twitter.com': + match = lxml.html.fromstring(item.content).xpath('//a/@data-expanded-url') + if len(match): + link = match[0] + clip = True + log(link) + # check cache and previous errors if link in cache: content = cache.get(link)