A script to interact with website

3 Antworten [Letzter Beitrag]
Sabrinakitty
Offline
Beigetreten: 06/17/2020

Hello
There is a translation website, I'm trying to use curl to download a page and then extract the translation from html code and display it in the terminal window. The site accepts method GET, the &s= part is a string to translate. I want to use this site, because it provides multiple translations of the same world. The site's interface is in some foreign language I can't understand, the translation itself is in proper language I need.
curl 'https://www.multitran.com/m.exe?l1=1&l2=11&s=computer' > translation.txt
The translation seems to be in blocks
<td class="trans" width="100%">...<td>
Is it possible to make a script to do it?

Magic Banana

I am a member!

Offline
Beigetreten: 07/24/2010

It is... but I will not "help" SaaSS abuse you: https://www.gnu.org/philosophy/who-does-that-server-really-serve.html

EDIT: Given a word, the site seems to return a fixed list of words, it may not be SaaSS after all, just published information. I will take a look at it.

Magic Banana

I am a member!

Offline
Beigetreten: 07/24/2010

I wrote that Shell script:
#!/bin/sh
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]
then
printf "Usage: $0 word ...
"
exit
fi
for word in "$@"
do
if [ -n "$2" ]
then
printf "* Translations for \"$word\":
"
fi
wget "https://www.multitran.com/m.exe?l1=1&l2=11&s=$(printf $word | sed 's/ /+/g')" -qO - | grep '^<td class="trans" width="100%">' | awk -F '[<>]' '{ print $5 }'
done

Sabrinakitty
Offline
Beigetreten: 06/17/2020

Thank you for the script and the article about SaaSS!
I will be careful to not use any SaaSS in the future.