inrocks backend

This commit is contained in:
Juke 2011-02-16 03:25:18 +01:00 committed by Romain Bignon
commit f05d4b2829
5 changed files with 101 additions and 32 deletions

View file

@ -18,12 +18,14 @@
import re
def id2url(_id):
regexp2 = re.compile("(\w+).(\w+).(.*$)")
regexp2 = re.compile("(\w+).([0-9]+).(.*$)")
match = regexp2.match(_id)
return 'http://www.20minutes.fr/%s/%s/%s' % ( match.group(1),
match.group(2),
match.group(3))
if match:
return 'http://www.20minutes.fr/%s/%s/%s' % ( match.group(1),
match.group(2),
match.group(3))
else:
raise ValueError("id doesn't match")
def url2id(url):
regexp = re.compile("http://www.20minutes.fr/(\w+)/([0-9]+)/(.*$)")
match = regexp.match(url)
return '%s.%d.%s' % (match.group(1), int(match.group(2)), match.group(3))
return url