Mercurial > eagle-eye
diff pyikriam/lazy/www/work/fetch.py @ 246:60c4b4b78a01
code clean
author | "Hisn Yi, Chen <ossug.hychen@gmail.com>" |
---|---|
date | Mon, 01 Dec 2008 00:25:07 +0800 |
parents | a4c364888197 |
children |
line wrap: on
line diff
--- a/pyikriam/lazy/www/work/fetch.py Fri Nov 14 02:05:48 2008 +0800 +++ b/pyikriam/lazy/www/work/fetch.py Mon Dec 01 00:25:07 2008 +0800 @@ -3,17 +3,6 @@ import cookielib import os -def install_opener(cookiefile): - COOKIEFILE = cookiefile - cj = cookielib.LWPCookieJar() - if os.path.isfile(COOKIEFILE): - cj.load(COOKIEFILE) - else: - cj.save(cookiefile) - opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) - opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.12pre) Gecko/20071220 BonEcho/2.0.0.12pre')] - urllib2.install_opener(opener) - class Fetcher: opener = None @@ -31,15 +20,14 @@ """ def __init__(self, working_product): self.working_product = working_product - - def get(self, data = {}): - """ - send datas via http get method. - """ - res = urllib2.urlopen(self.working_product.source, urllib.urlencode(data)) - return res.read() - def post(self, data = {} ): + def get(self, **kwds): + return self.open(kwds) + + def post(self, **kwds): + return self.open(kwds) + + def open(self, data = {} ): """ send datas via http post method.