Skip to content

Instantly share code, notes, and snippets.

@gapato
Created July 18, 2014 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gapato/ffdc3eb7b48e98968f94 to your computer and use it in GitHub Desktop.
Save gapato/ffdc3eb7b48e98968f94 to your computer and use it in GitHub Desktop.
Grab phone number from leboncoin.fr ad url or id
#!/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