Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt download amendements to new API #164

Merged
merged 11 commits into from
Jan 3, 2021
1 change: 1 addition & 0 deletions batch/amendements/compute_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ echo 'SELECT source FROM amendement WHERE sort LIKE "Ind%" AND date > DATE_SUB(C
grep -v source > liste_sort_indefini.txt

python3 download_amendements.py $LEGISLATURE > /tmp/download_amendements.log
python3 download_amendements_indefinis.py >> /tmp/download_amendements.log

for file in `ls html`; do
fileout=$(echo $file | sed 's/html/json/' | sed 's/\.html/\.xml/')
Expand Down
6 changes: 4 additions & 2 deletions batch/amendements/download_amendements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

legislature = sys.argv[1] if len(sys.argv) > 1 else 15
count = 0
count2 = 0

now = datetime.datetime.now()
day = int(now.strftime("%d"))
Expand Down Expand Up @@ -52,4 +51,7 @@

with open(f'html/{texte}-{organe}-{num}.html', 'w') as f:
f.write(resp.text)
datedebut += datetime.timedelta(days=1)
count += 1
datedebut += datetime.timedelta(days=1)

print(count, 'amendements téléchargés')
17 changes: 17 additions & 0 deletions batch/amendements/download_amendements_indefinis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import requests

count = 0

for url_amdt in open('liste_sort_indefini.txt'):
url_amdt = url_amdt.strip()
print(url_amdt)
resp = requests.get(url_amdt, cookies={'website_version': 'old'})
if resp.status_code != 200:
print('invalid response')
continue
slug = url_amdt.replace('/', '_')
with open(f'html/{slug}.html', 'w') as f:
f.write(resp.text)
count += 1

print(count, 'amendements indefinis téléchargés')
RouxRC marked this conversation as resolved.
Show resolved Hide resolved