absence-AN
By: a guest | Apr 19th, 2009 | Syntax:
Bash | Size: 1.50 KB | Hits: 229 | Expires: Never
#!/bin/bash
# License BSD - Benjamin GIGON / Prae
function get_info {
local DEPUTEID=$1
local DOCTYPE=$2
lynx -source "http://recherche2.assemblee-nationale.fr/resultats_tribun.jsp?id_auteur=${DEPUTEID}&legislature=13&typedoc=${DOCTYPE}" \
| grep '<span class="nbres">' \
| html2text \
| sed 's/^[[:space:]]*\(.*\)[[:space:]]*$/\1/' \
| sed -e "s/ /+/g" \
| bc
}
function get_listing {
lynx "http://www.assemblee-nationale.fr/13/tribun/xml/liste_alpha.asp" -dump \
| grep "fiches_id" \
| awk '{ print $2 }'
}
function get_name {
local DEPUTEID=$1
lynx -source "http://www.assemblee-nationale.fr/13/tribun/fiches_id/${DEPUTEID}.asp" \
| grep -rs "<title>" \
| awk -F':' '{ print $2 }' \
| html2text
}
echo ";ID;Nom Depute;Interventions Seances;Interventions Commissions;Rapports Informations;Propositions Lois;" 2> /dev/tty
echo "Nombre total:`get_listing | wc -l`" 1> /dev/tty
get_listing | while read LINK;
do
DEPUTE_ID=`basename $LINK .asp`;
DEPUTE_NAME=`get_name ${DEPUTE_ID}`
INTERVENTION_SEANCES=`get_info "${DEPUTE_ID}" "ComptesRendusIntegraux"`
INTERVENTION_COMMISSIONS=`get_info "${DEPUTE_ID}" "ComptesRendusReunions"`
RAPPORTS_INFO=`get_info "${DEPUTE_ID}" "Rapports"`
PROPOSITIONS_LOIS=`get_info "${DEPUTE_ID}" "PropositionsLoi"`
echo ";${DEPUTE_ID};${DEPUTE_NAME};${INTERVENTION_SEANCES};${INTERVENTION_COMMISSIONS};${RAPPORTS_INFO};${PROPOSITIONS_LOIS};" 2> /dev/tty
let index=${index}+1;
printf "Processing: #%d\r" ${index} 1> /dev/tty
done;