Marrant,

Je le faisait avec jq:

  $ getLocal() {
    wget -qO - "https://www.local.ch/api/autosuggestions?limit=10&q=$1"; |
        jq -r '.[] | select(.entryID != null) | .what, .where,.type,.entryID'
  }

  $ getLocal 0244545404
  Hauri Félix
  Rue Centrale 4, 1450 Ste-Croix
  BUSINESS
  6Dly--bimDw9H5LfIdeoyA

Mais cela n'affiche pas la profession... J'en suis revenu à wget|sed...

  $ getLocal() {
    wget -qO - "https://www.local.ch/fr/s/$1"; |
      sed -e '1,/<h2 .* data-testid="title">/{
         s/.*data-testid="title">//;ta;d;:a;};
         s@</section>.*@@g;
         s/<[^>]*>/\n/g;s/\n\n\+/\n/g'
  }

  $ getLocal 0244545404
  Hauri Félix
  Rue Centrale 4, 1450
 
  Ste-Croix
  Conseils et prestations en informatique

Pas très beau, mais semble fonctionner...

-- 
 Félix Hauri  -  <[email protected]>  -  http://www.f-hauri.ch
_______________________________________________
gull mailing list
[email protected]
https://forum.linux-gull.ch/mailman/listinfo/gull

Répondre à