Skip to content

Instantly share code, notes, and snippets.

@dergachev
Created July 3, 2014 16:58
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 dergachev/64a31d2dd8a84c866323 to your computer and use it in GitHub Desktop.
Save dergachev/64a31d2dd8a84c866323 to your computer and use it in GitHub Desktop.
google-translation-experimentation
working:
@echo "WORKING"
time curl 'https://translate.google.com/translate_a/single?client=t&sl=fr&tl=en&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&oc=1&prev=conf&psl=auto&ptl=en&otf=1&it=sel.7964&ssel=3&tsel=0&q=contravention' \
-H 'pragma: no-cache' -H 'accept-encoding: gzip,deflate,sdch' -H 'accept-language: en-US,en;q=0.8,fr;q=0.6' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' -H 'x-chrome-uma-enabled: 1' -H 'accept: */*' -H 'cache-control: no-cache' \
-H 'referer: https://translate.google.com/' \
-H 'x-client-data: CMy1yQEIlLbJAQiltskBCKm2yQEIxLbJAQi4iMoBCOmIygEIqZTKAQ==' \
--compressed \
| jq '.'
query=contravention
filter=.[5][0][2]
exp:
time curl 'https://translate.google.com/translate_a/single?client=at&sl=fr&tl=en&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&oc=1&prev=conf&psl=auto&ptl=en&otf=1&it=sel.7964&ssel=3&tsel=0&q=$(query)' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' \
| perl -pe 's/,(?=,|])/,[]/g' \
| jq '$(filter)'
# asking for less "features"
exp2:
time curl 'https://translate.google.com/translate_a/single?client=p&sl=fr&tl=en&dt=t&ie=UTF-8&oe=UTF-8&oc=1&prev=conf&psl=auto&ptl=en&otf=1&it=sel.7964&ssel=3&tsel=0&q=$(query)' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' \
| perl -pe 's/,(?=,|])/,[]/g' \
| jq '$(filter)'
# this is used by babelfrog;
exp3:
time curl 'http://translate.google.com/translate_a/t?client=p&hl=en&&ie=UTF-8&oe=UTF-8&ssel=0&tsel=0&sl=auto&tl=en&q=$(query)&multires=1&uptl=fr&oc=3' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' \
| jq '$(filter)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment