Created
July 18, 2014 16:48
-
-
Save gapato/ffdc3eb7b48e98968f94 to your computer and use it in GitHub Desktop.
Grab phone number from leboncoin.fr ad url or id
This file contains 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/sh | |
PHONE_API_URL=http://www2.leboncoin.fr/ajapi/get/phone?list_id= | |
quit () { | |
echo "No phone number for this ID" | |
exit | |
} | |
while (($#)); do | |
id=$1 | |
if [[ $id =~ ^http.*$ ]]; | |
then | |
id=$(echo $id | sed 's/http.*\///' | sed 's/\.htm.*//') | |
fi | |
img_url=$(curl -L -s $PHONE_API_URL$id | cut -d'"' -f 4) | |
img_url=${img_url%%[[:space:]]} #trim newline | |
[ "$img_url" ] || quit #quit if no response | |
img_url_stripped=${img_url//\\} | |
curl -s $img_url_stripped > /var/tmp/lbc-$id.gif | |
gocr -C 0-9 /var/tmp/lbc-$id.gif | |
rm /var/tmp/lbc-$id.gif | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment