/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import string, urllib def clean(text): return ' '.join(string.replace(text.strip(), "\n", ' ').split()) def translate(frase, da, a): frase = clean(frase) params = urllib.urlencode({'BabelFishFrontPage':'yes','doit':'done','urltext':frase,'lp':da+'_'+a}) response = urllib.urlopen('http://babelfish.altavista.com/tr', params) import time print params time.sleep(1) f = open("prova.html","w") html = response.read() f.write(html) f.close() print html