Created
December 18, 2019 11:27
-
-
Save cquest/39bb449b6c09318af3108e5cb112b95b to your computer and use it in GitHub Desktop.
login et téléchargement de PDF sur data.inpi.fr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# téléchargement de documents PDF sur data.inpi.fr | |
if [ $# -ne 1 ]; | |
then | |
echo "Usage: ./download SIREN" | |
echo "example: ./download SIREN 429211592" | |
exit | |
fi | |
DIR=$(echo $1 | sed 's!\([0-9][0-9][0-9]\)\([0-9][0-9][0-9]\)\([0-9][0-9][0-9]\)!\1/\2/\3!') | |
mkdir -p $DIR | |
curl -b cookie -s "https://data.inpi.fr/documents/list/companies/$1" | jq . | sed 's/\(".*"\): ".*"\(.*$\)/\1\2/;s/\(".*"\): {/\1: [/;s/ }/ ]/' | jq . -c > $DIR/$1.json | |
for D in $(jq .bilans[] -r $DIR/$1.json) | |
do | |
curl -b cookie -s "https://data.inpi.fr/documents/$D" > $D.json | |
jq .data -r $D.json | base64 -d > $DIR/$1-B-$D.pdf | |
rm $D.json | |
done | |
for D in $(jq .actes[] -r $DIR/$1.json) | |
do | |
curl -b cookie -s "https://data.inpi.fr/documents/$D" > $D.json | |
jq .data -r $D.json | base64 -d > $DIR/$1-A-$D.pdf | |
rm $D.json | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# script de login sur data.inpi.fr | |
if [ $# -ne 1 ]; | |
then | |
echo "Usage: ./login EMAIL PASSWORD" | |
echo "example: ./login [email protected] monSuperPass" | |
exit | |
fi | |
# récupération des cookies initiaux et du token CSRF | |
TOKEN=$(curl -s https://data.inpi.fr/login -c cookie | grep "login_form__token" | sed 's/^.*value="//;s/".*$//') | |
# login et mise à jour des cookies | |
curl -s 'https://data.inpi.fr/login' -b cookie -c cookie \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
--data "referer=https%3A%2F%2Fdata.inpi.fr&login_form%5BEmail%5D=$1&login_form%5Bpassword%5D=$2&login_form%5Blicence%5D=1&login_form%5Bsubmit%5D=&login_form%5B_token%5D=$TOKEN" \ | |
> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment