Last active
March 23, 2023 12:17
-
-
Save rshipp/95ee7c36f6cdc57b988d to your computer and use it in GitHub Desktop.
Scrape the highest rated MP3 from Forvo.com for a given word
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/bash | |
# Forvo scraper | |
language=${FORVO_LANG:-fr} | |
BASEURL="http://forvo.com/search/" | |
AUDIOURL="http://audio.forvo.com/mp3/" | |
word=$1 | |
if [[ -z $word ]]; then | |
echo "usage: " | |
echo "FORVO_LANG=languagecode ./forvo_scraper.sh myword" | |
echo "for example: " | |
echo "FORVO_LANG=fr ./forvo_scraper.sh chien" | |
echo "will save a single file named 'chien.mp3' in the current folder" | |
exit | |
fi | |
url="${BASEURL}${word}/${language}" | |
playurl="${BASEURL}${word}/#${language}" | |
file="$(wget -qO- "${url}" | grep 'onclick="Play(' | head -1 | sed "s/^.*Play(.*,'\([^']*\)','.*$/\1/g" | base64 -d)" | |
wget -qO"${word}.mp3" "${AUDIOURL}${file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! I updated your script to make it work again.