Public
Snippet $401 authored by SpF

faq.sh

faq.sh
#!/bin/bash
# USAGE :
#
# $ ./faq.sh
# https://contact.framasoft.org/foire-aux-questions/
# $ ./faq.sh sphere
# https://contact.framasoft.org/foire-aux-questions/#sphere_liaison_facebook
# https://contact.framasoft.org/foire-aux-questions/#sphere_liaison_worpdress_com
# https://contact.framasoft.org/foire-aux-questions/#sphere_restaurer_un_compte
# https://contact.framasoft.org/foire-aux-questions/#sphere_CSRF
# https://contact.framasoft.org/foire-aux-questions/#sphere_choc
# https://contact.framasoft.org/foire-aux-questions/#sphere_porn
# https://contact.framasoft.org/foire-aux-questions/#sphere_modo
# https://contact.framasoft.org/foire-aux-questions/#sphere_signaler
# $ ./faq.sh sphere facebook
# Je n'arrive pas à publier sur Facebook : https://contact.framasoft.org/foire-aux-questions/#sphere_liaison_facebook

Q=$(curl -s https://contact.framasoft.org/foire-aux-questions/ | grep "$1" | grep "<h3" | grep "$2" | cut -d\> -f 4 | sed "s/<\/h3//g; s/\&\#160\;/ /g; s/&rsquo\;/\'/g")
URL=$(curl -s https://contact.framasoft.org/foire-aux-questions/ | grep "$1" | grep "<h3" | grep "$2" | cut -d\" -f 4)

if [[ -z "$*" ]]; then # Si pas d'arguements
  echo "https://contact.framasoft.org/foire-aux-questions/"
elif [[ -z "$2" ]]; then # Si pas de recherhe spécifique : liste
  for i in $URL
  do
    echo "https://contact.framasoft.org/foire-aux-questions/#"$i
  done
else # Si service + recherhe
  echo "$Q : https://contact.framasoft.org/foire-aux-questions/#$URL"
fi