add export_thread
add export_thread to boobmsg working show_thread
This commit is contained in:
parent
3c33a53a3b
commit
fe7b8d082c
3 changed files with 29 additions and 5 deletions
|
|
@ -256,6 +256,14 @@ class Boobmsg(ReplApplication):
|
||||||
self.format(thread)
|
self.format(thread)
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
def do_export_thread(self, arg):
|
||||||
|
id, backend_name = self.parse_id(arg)
|
||||||
|
cmd = self.do('get_thread', id, backends=backend_name)
|
||||||
|
for backend, thread in cmd:
|
||||||
|
for m in thread.iter_all_messages():
|
||||||
|
self.format(m)
|
||||||
|
|
||||||
|
|
||||||
def do_show(self, arg):
|
def do_show(self, arg):
|
||||||
"""
|
"""
|
||||||
show MESSAGE
|
show MESSAGE
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,17 @@ class Newspaper20minutesBrowser(BaseBrowser):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_content(self, _id):
|
def get_content(self, _id):
|
||||||
self.location(id2url(_id))
|
try :
|
||||||
|
url = id2url(_id)
|
||||||
|
except ValueError:
|
||||||
|
url = _id
|
||||||
|
try:
|
||||||
|
self.location(url)
|
||||||
|
except IndexError:
|
||||||
|
if _id == '':
|
||||||
|
raise ValueError("thread id is empty")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
except AttributeError:
|
||||||
|
raise ValueError("cant go on url")
|
||||||
return self.page.article
|
return self.page.article
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,15 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
def id2url(_id):
|
def id2url(_id):
|
||||||
regexp2 = re.compile("(\w+).(\w+).(.*$)")
|
regexp2 = re.compile("(\w+).([0-9]+).(.*$)")
|
||||||
match = regexp2.match(_id)
|
match = regexp2.match(_id)
|
||||||
return 'http://www.20minutes.fr/%s/%s/%s' % ( match.group(1),
|
if match:
|
||||||
match.group(2),
|
return 'http://www.20minutes.fr/%s/%s/%s' % ( match.group(1),
|
||||||
match.group(3))
|
match.group(2),
|
||||||
|
match.group(3))
|
||||||
|
else:
|
||||||
|
raise ValueError("id doesn't match")
|
||||||
|
|
||||||
def url2id(url):
|
def url2id(url):
|
||||||
regexp = re.compile("http://www.20minutes.fr/(\w+)/([0-9]+)/(.*$)")
|
regexp = re.compile("http://www.20minutes.fr/(\w+)/([0-9]+)/(.*$)")
|
||||||
match = regexp.match(url)
|
match = regexp.match(url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue