From d39604c453766c69daf9c0117d2c690c74ffc6ac Mon Sep 17 00:00:00 2001 From: pictuga Date: Mon, 25 Feb 2013 20:53:59 +0100 Subject: [PATCH] Support for cookies added NYT needs them --- morss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/morss b/morss index 2ebd6b0..a545cc1 100755 --- a/morss +++ b/morss @@ -1,9 +1,11 @@ #! /usr/bin/env python2.7 import sys import os +from os.path import expanduser from lxml import etree import urllib2 -from os.path import expanduser +import urllib +from cookielib import CookieJar def log(str): if (len(sys.argv) == 3): @@ -39,7 +41,9 @@ for item in items: desc.text = open(cached, 'r').read() else: try: - data = urllib2.urlopen(link).read() + cj = CookieJar() + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) + data = opener.open(link).read() html = etree.HTML(data) match = html.xpath(node)