How to translate a complete web page?

Translate web page from shell

  • I'm trying to do translate a web page automatically with a shell script. Here is the interesting part: wget http://www.google.com/translate?langpair=en%7Ces&u=http%3A%2F%2Fasdf.com I'm getting the "ERROR 403: Forbidden" even though I can get the translation when using this URL in browser. Could someone explain what's going on? Why google forbids the "translator" usage from shell script? Do they monitor user agent or they have another way to tell if you are a browser or not? If someone knows another way to do it (for example if there is a console non-interactive browser that would fetch that URL or, perhaps there is another online translation tool I'm not aware of) please let me know.

  • Answer:

    Yes, they check the user agent. Add the -U option to wget, like this: wget -U "Mozilla/5.0" 'http://www.google.com/translate?langpair=en%7Ces&u=http%3A%2F%2Fasdf.com' I tested on my machine and I was able to get the page. Update: Make sure you put quotes around the url (I used single quotes), because the & separator backgrounds everything before it, and the rest gets interpreted as a separate command.

facha at Server Fault Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.