inrocks backend
This commit is contained in:
parent
08252358eb
commit
f05d4b2829
5 changed files with 101 additions and 32 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue