Commit 0e1cd65d authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

abstraction

parent 0b72d345
......@@ -30,6 +30,26 @@ import re
import time
import configobj
def get_articles_from_page(link):
articles={}
r = requests.get(link)
reg = '^.*?<a href="(affichCodeArticle\.do[^"]*idArticle[^"]*)" title="En savoir plus sur l\'article ([^"]+)"'
c=r.content
while True:
a = re.match(reg, c, re.DOTALL)
if a is None:
break
l1 = 'https://www.legifrance.gouv.fr/'+a.groups()[0]
l1 = re.sub('&amp;','&',l1)
l1 = re.sub(';jsessionid=[^\?]*\?','?',l1)
l1 = re.sub('&dateTexte=[^&]*','',l1)
articles[a.groups()[1]] = l1
c = re.sub('href=','',c,1)
return articles
def get_code(codename,codeids):
if not codeids.has_key(codename):
......@@ -55,23 +75,7 @@ def get_code(codename,codeids):
articles = {}
for link in links:
r = requests.get(link)
reg = '^.*?<a href="(affichCodeArticle\.do[^"]*idArticle[^"]*)" title="En savoir plus sur l\'article ([^"]+)"'
c=r.content
while True:
a = re.match(reg, c, re.DOTALL)
if a is None:
break
l1 = 'https://www.legifrance.gouv.fr/'+a.groups()[0]
l1 = re.sub('&amp;','&',l1)
l1 = re.sub(';jsessionid=[^\?]*\?','?',l1)
l1 = re.sub('&dateTexte=[^&]*','',l1)
articles[a.groups()[1]] = l1
c = re.sub('href=','',c,1)
return articles
articles.update(det_articles_from_page)
class codes:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment